Date is a command line utility for printing or setting the date and time.

learn more… | top users | synonyms

2
votes
1answer
113 views

Any better method than this for sorting files by their creation date?

I needed to display a list of directories sorted by their creation date and I came up with this code snippet that I thought was kind of clever. Is there a more obvious way to do this that I'm missing? ...
3
votes
3answers
4k views

Subtracting dates in unix

Is there a way in unix to subtract a month or at least 30 days from a specific date? The date is to be inputted by the user. Example: 2012-11-19 - 1 month = 2013-10-19 This one doesn't work: date ...
1
vote
2answers
1k views

How to print dates between two different dates [duplicate]

I want to print dates between 2 different dates (i.e. start date and two dates) If start date is 2013-09-05 and end date is 2013-09-10, then I want result as 2013-09-05 2013-09-06 2013-09-07 ...
10
votes
3answers
2k views

What is the recommended way to synchronize time using NTP?

This question has come up a number of times in a localized way, this question is meant to provide the preferred/best method for synchronizing a system's clock using NTP. The solution should handle ...
3
votes
2answers
2k views

How to force the time and date settings to refresh from the internet?

I'm running Ubuntu 12.04 LTS under vmWare. When I restart a suspended image, the system clock doesn't detect that the system time is out of date. In the Time and Date settings dialog, I've selected ...
2
votes
1answer
2k views

Unix last password change date

My understanding is that the last change date(in /etc/shadow) is the number of days since 01/01/1970 that the password was changed, but I'm seeing numbers like 19708 which translate to 17/12/2023 ...
1
vote
2answers
107 views

How to set and read time w/o language barrier in linux?

Currently when you run the command date the output is Wed Sep 18 07:23:28 EDT 2013 and if you want to change the date you'd have to run date -s "18 SEP 2013 07:15:00" if you try to change ...
0
votes
3answers
104 views

If you want to get a future date, why can't you just get the current date and use sed/awk/etc?

I've just looked at this question. The first answer states how to get a future date directly from the date command. Why couldn't you just use text manipulation to increment the date? Basically: date ...
1
vote
3answers
4k views

How to convert from one date format to other format?

I have one problem with my date format. I want to change from one format to the other and vice versa. My date formats are Format 1 YYYY-MM-DD Format 2 MM/DD/YYYY I want to change format 1 to ...
3
votes
0answers
68 views

How do I recursively set the date created attribute to the date modified attribute on NTFS-3G?

In my first question, I asked how to get the "Date created" field in NTFS-3G. Now, that I know I can get the "Date created", I have started adding files onto my NTFS-3G partition and would like to set ...
0
votes
2answers
151 views

Transform list of files (with date) into list of dates

I have a directory where I store backups. The are in the format Complete Backup YYYY-MM-DD hh-mm-ss.tar.bz2 I have found out that you can feed a date into the date command using date --date="YY-MM-DD ...
2
votes
3answers
185 views

how to create a data file with a column of date from day1 to dayN?

I was wondering if I could generate a hourly or daily time step date in a column starting from some year in the past to some day in the near past or today. to be more clear, I want to create one ...
2
votes
4answers
368 views

How to get a previous date using a reference to a file with the date command?

I'm trying to get Previous date of reference file. What I've tried : [rahul@testsrv]$ date +%F -r /tmp/ftpbkp.log 2013-08-27 [rahul@testsrv]$ date +%F -r /tmp/ftpbkp.log -d "1 day ago" date: the ...
1
vote
3answers
1k views

How to combine bash arithmetic with command output?

Suppose you had two commands: First command let foo=2+2 echo $foo 4 Second command date "%s" 1377107324 How would you combine them? Attempt 1. echo The epoch time is: `date +%s` in 100 ...
1
vote
2answers
366 views

Moving Older Version Files to another folder via a script [closed]

I am trying to find a way of getting my cmd script to look through my folder, find the older versions of the pdf docs in the folder and move them to another folder called older versions. Problem I am ...
0
votes
1answer
173 views

How do you time how long a command took to run? [duplicate]

How would you find out how long a running process took to complete? Example: date; dd bs=1m if=/foo of=bar; date ^This example only has 1 second of resolution. Any shell is acceptable.
1
vote
1answer
2k views

convert timestamp to formatted time OSX

I had this working on Ubuntu but I'm now trying to run the script on OSX but it seems that the formatting of date is different. Originally I had: date -d "$MODDATE" +%F" "%H":"%M where $MODDATE is ...
3
votes
3answers
201 views

sort lines according to day

I have a text file in following format, and I need to sort the lines according to date. Is there some simple way to do it (preferably in bash) ? 2013-May-30 2 2013-May-21 10 2013-Jun-27 8 ...
0
votes
2answers
3k views

Date time in Linux bash [closed]

I am trying to display a date time in the form of 07/08/2013 16:52:13 by using command in bash script: dt=`date '+%d/%m/%Y_%H:%M:%S'` which variable is used to populate a CSV file. The only ...
1
vote
4answers
215 views

log file: only process entries older than “MMM DD HH:MM:SS”

I need to process my logfile /var/log/mylogs.log. I am only interested in the new entries, lets say, since Jul 20 15:00:00 but the log contains older entries as well. Is there any simple way, how I ...
1
vote
1answer
89 views

GNU date epoch +%s vs. now in timestamp phrases with computations including months?

I am trying to do date computations in a shell script using gnu date with timestamp phrases and fail to explain these differences. Can someone enlighten me? Is this a bug? % date -u -d "now" Fri Aug ...
1
vote
1answer
1k views

How to set system time from Unix timestamp

I know arbitrary timestamp and I want to set system time using it. I've tried following: date +%s -s "1371729865" date +%s -s '1371729865' date +%s -s 1371729865 but without success. The idea is, ...
1
vote
2answers
48 views

How to write out the next 3 or X days with a command?

I can give the day for today in a command: TODAY=`date +%Y.%m.%d.` but how can I give out the next 3 or X days in a command? (Ubuntu 12.04)
0
votes
3answers
45 views

how to touch files like report-07/05/13

when I want to touch files like report-05/07/13 with command touch report-$(date +%D) it gives me an error like this: touch: cannot touchreport-07/05/13': No such file or directory` How can I build ...
2
votes
2answers
2k views

How to find files by the time in their filename? [duplicate]

We have a directory contains files which contains time in their filename ./test.2013-06-11_06-01.gz ./test.2013-06-12_01-01.gz ./test.2013-06-13_03-01.gz ./test.2013-06-14_03-01.gz ...
6
votes
1answer
2k views

Removing leading zeros from DATE

I made an alias of the date command to display date in the following format: 2013.06.14.12.10.02 using this command: alias date = date +"%Y.%m.%d.%H.%M.%S" Everything works great, except I ...
2
votes
5answers
3k views

How do I set time and date from the Internet?

How do I retrieve the date from the Internet and set my computer's clock, from the command line?
17
votes
3answers
2k views

How does touch -t work internally?

How does touch -t command works exactly, internally (I tried to find its source code but couldn't)?
1
vote
2answers
126 views

agonizing over the Unix epoch [closed]

I am having some trouble understanding what exactly 00:00:00 Coordinated Universal Time (UTC), 1 January 1970 means. Below are two possible ways to interpret 00:00:00 according to my understanding, ...
0
votes
4answers
68 views

How to make 1:52 to 01:52 with eg.: sed?

INPUT: a|2013.06.13. 13:22|xx b|2013.06.13. 1:52 |xx c|2013.06.13. 2:26 |xx OUTPUT: a|2013.06.13. 13:22|xx b|2013.06.13. 01:52 |xx c|2013.06.13. 02:26 |xx How can I make the 1:52 to 01:52 in ...
2
votes
1answer
6k views

Read log file between two dates

I have to read log file between and my question is how to get only the text in the file wich is between two dates using unix commands? Every line contain date and I want to get the text in the file ...
2
votes
2answers
4k views

Linux listing files between two date without touch command

I need a command which will list the files between given date and time (YYYYMMDDHHMMSS - format) in to a text file. I don want to use touch command as its creating permission issue. I am new to this ...
0
votes
2answers
81 views

Executing a program according to the last modified date

I need to write a script which would execute some executables in a directory according to the last modified date. The oldest should run first. How do I do it? This is what I have done so far for f ...
4
votes
1answer
89 views

How does coreutil's date manage to get such weird results?

I was playing around with date to try to convert expressions such as "2 hours" to a number of seconds like 7200. I thought I could perform this with invocations such as: date -d "1970-01-01 00:00:00 ...
1
vote
1answer
86 views

How to display Discordian date?

I am a strong believer in Discordianism. Yet most mostly I am confronted with the time measurement of pesky heathens. How do I know what date it really is?
3
votes
4answers
5k views

Command 'date +FORMAT' — What are %a, %A, %b, etc. called?

The date command outputs the current date and time like this: Fri Apr 12 15:04:03 UTC 2013. To have the output date-time in a custom format we can use date +FORMAT, for example, like this: date ...
2
votes
2answers
4k views

How to scp/tar files that are in between specific days?

I need to copy db log files between two suse servers where I am interested in files ONLY in between 10.3.2013 - 13.3.2013 It is desired to compress the files before copying so I tar them and scp. ...
3
votes
2answers
6k views

Correct use of TZ, date, and hwclock?

I'm working on an Buildroot developed ARM/ulibc Linux distribution for a custom board. I'm trying to understand the relationship between If I do this, as I've seen on a few examples online: # date ...
5
votes
3answers
2k views

how to suppress bash octal number interpretation? (to be interpreted as decimal)

I have this: date +"%H hours and %M minutes" I use festival to say it up.. but it says like: "zero nine hours".. I want it to say "nine hours"! but date always give me 09... so I wonder if bash ...
1
vote
1answer
294 views

Unix Date command not working for few servers

I am trying to execute date command in unix server for yesterday. The commands tried are : date --date ="1 day ago" date --date ="1 days ago" date --date ="yesterday date --date ="-1 day" These ...
2
votes
3answers
115 views

Filter a list of strings using math

I have a directory with files listed like so: abc201303130110.txt abc201303140511.txt abc201303150112.txt As you can see, the filename contains a datetime stamp. I want to return all files with the ...
3
votes
1answer
62 views

How to edit files in-place while performing operation on the values matching the searched pattern?

Given a list files containing random text and many datetimes in ISO format in it (e.g "2012-07-02T10:47:24+02:00"), how can I find all these datetimes and add 2 hours to each one ? Ideally a solution ...
0
votes
1answer
270 views

expr command used to work and stopped

I am on SunOS machine trying to get the date string of the past minute, yesterday I used this command I found on the internet expr `date +%Y%m%d%k%M` - 1 which is worked just fine and I saw the ...
2
votes
2answers
2k views

How do I use an If-Else query based on the day of the week?

Problem: I need to check if today is Thursday and perform different actions based on the result of this condition. I tried two different approaches: Getting the Day Name: DAYOFWEEK=$(date +"%a") ...
1
vote
1answer
770 views

How to check Today's Day and Search Files

Problem: I need to find out today's date and search a file which contain's today's date in the name. Also another file which contains Yesterday's date. I was able to do so by something like: ...
2
votes
2answers
224 views

Select greatest numbered filename

Simple requirement but can't find anything online which can achieve it. I have a list of dated files as below... filename_20120101.dat filename_20120102.dat filename_20120103.dat I ...
2
votes
1answer
2k views

Create sub-directories and organize files by date

I have some directories of files copied from my security camera that I would like to organize into sub-directories by file date. So for example; -rwxrwxrwx 0 root root 4935241 Jul 19 2012 ...
3
votes
2answers
167 views

Changing the localization

I have SSH access to a CentOS 6.3 box. Some results on that SSH and I think the whole OS is localized to portuguese. When I type date, for example, I get Sex Fev 15 02:35:48 WET 2013 instead of ...
2
votes
2answers
696 views

Displaying a specific date

I'm trying to display a specific date in Unix, using the date command, I can't figure out how to display a date other than today's date. For example, if I was trying to display July 4, 2011 I use $ ...
6
votes
2answers
7k views

Good method to compare time?

I need to check for the current time and abort the script if it is not proper time of day I am supposed to run it. Also, if anyone else runs it, it should abort. For example: I need my script to only ...