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

learn more… | top users | synonyms

2
votes
2answers
108 views

Specify consistent week boundaries using date

I need to run a certain program passing it the week boundaries. (I use CentOS release 6.4, so a bash/gnu date solution is fine). I tried this yesterday (on Monday): for ((w=1;w<=6;w++)) do ...
4
votes
2answers
68 views

Off by 1 year error in GNU date?

Right now, 2014-01-06, GNU date 8.4 on CentOS release 6.4, does this: $ date --date "last week" +"%Y-%V" 2013-01 On the other hand, $ date --date "last week" +"%Y-%U" 2013-52 which is just ...
5
votes
5answers
2k views

How to parse ISO8601 dates with linux date command

I'm trying to use the date command to generate a file timestamp that the date command itself can interpret. However, the date command does not seem to like its own output, and I am not sure how to ...
1
vote
1answer
210 views

how to subtract a constant value from a data file?

I want to subtract a constant number from my data to get new data file. For example, I want to subtract 10 from my data. data.txt Id a b c d e 1 1 2 3 4 5 2 2 3 4 5 6 ...
2
votes
5answers
4k views

Extract date from a variable in a different format

Let me explain you the problem $ date +%c -d "$d" Tue 31 Dec 2013 01:13:06 PM CET $ date +'Today is %F' -d "$d" Today is 2013-12-31 This solution corresponds to current date. But I have one ...
0
votes
0answers
15 views

UNIX: How to extract date from a variable storing a UNIX DATE [duplicate]

I am facing following issue: Input: F=`date +%Y%m%d` echo $F Output: F=20131231 But when trying this(File Name:A.sh): C=`date` G=`$C +%Y%m%d` echo $C echo $G Output: A.sh[6]: Tue: not ...
4
votes
1answer
105 views

Midnight Commander, using date in User menu

I would like to use MC (midnight commander) to compress the selected dir with date in its name, e.g: dirname_20131231.tar.gz The command in the User menu is : tar -czf dirname_`date ...
3
votes
3answers
1k views

How to delete 2 months back files in unix

Say I have below log files, AA_XX_20130719185428.log exec_xxx_cpb_20130712182453.log 13122013121327_AR_INC_DOBC_1.dprf.log 24122013_masterscript.LOG Date part contains both date and time. I want ...
45
votes
3answers
5k views

Day of week {0-7} in crontab has 8 options, but we have only 7 days in a week

Day-of-week: Allowed range 0 – 7. Sunday is either 0 or 7. I found this after Googling, my question is why should both values (0,7) correspond to Sunday?
6
votes
4answers
666 views

convert date format in log

I have a log with following date format: 2013-12-14 18:53:33 aaaaaaaaaaaaaaaa 2013-12-14 18:53:33 bbbbbbbbb 2013-12-14 18:53:33 ccccccccccccccccccccc What would be the simplest solution to convert ...
3
votes
4answers
822 views

Searching a pattern in file names with number

I have a large number of files in a folder each with the date as the filename. For example 20130101 20130102 20130103 . . . 20130131 similarly for other months 20130201 to 20130230, the pattern is ...
7
votes
3answers
526 views

Why does TZ=UTC-8 produce dates that are UTC+8?

The current time in Los Angeles is 18:05. But when I run TZ=UTC-8 date --iso=ns, I get: 2013-12-07T10:05:37,788173835+0800 The date utility tells me that the time is 10:05, and even says that it's ...
3
votes
2answers
248 views

mutt: conditional date format in “index_format”

I have following value set for index_format in mutt: "%Z %{%Y %b %e %H:%M} %?X?(%X)& ? %-22.22F %.100s %> %5c " which displays date in the format as 2013 Dec 5 I was wondering whether ...
4
votes
3answers
225 views

What could be the use case of changing modified time of a file to the future?

I was reading through the man page of ls on UNIX, specifically OS X Mavericks. This got me intrigued: If the modification time of the file is more than 6 months in the past or future, then the ...
2
votes
3answers
88 views

get list of months using dseq from dateutils

how'd I get a listing of the months in the year (abbreviated) using dseq from dateutils? NOTE simply running: dseq 'jan' 'dec' -i '%b' -f '%b' returns a humongous list of months: piping the ...
4
votes
2answers
215 views

Create sub-directories and organize files by date from file name

I have been using the following script to organize my photos into "Date' Directories: for x in *.JPG; do d=$(date -r "$x" +%Y-%m-%d) mkdir -p "$d" mv -- "$x" "$d/" done This script works ...
2
votes
1answer
69 views

date doesn't accept its own output

What is the option for date to give output in a format acceptable to date --set ? I'm trying to remotely set the date, using the current computer clock of my workstation. ssh user@host sudo date ...
1
vote
1answer
125 views

who -b date format varies strangely

I run who -b to get the date of the last reboot. It returns 2013-10-29 14:55. Now ran by a daemon (I am sending this date to a server) it returns Oct 29 14:55. But some other times (before last reboot ...
0
votes
3answers
2k views

Convert Month Number to Month Name

is there a way to convert month number to name? example: 2013-10-22 will become Oct 22 I don't have the GNU date and my OS is AIX.
2
votes
1answer
175 views

Change System Time/Date

I'm running Linux Mint 15 with KDE 4.10.4+ Here's what I get when I run date: user:~ > date Die Okt 29 15:47:54 UTC 2013 Where "Die Okt" indicates a German-language setting, which I don't ...
4
votes
1answer
67 views

date modifiers explained

Again, I found some interesting I don't understand in an info page, in info dateto be precisely: An optional modifier can follow the optional flag and width specification. The modifiers are: ...
4
votes
5answers
3k views

Next day of the user entered date - date +1 day

I am new to scripting I needed a script in the AIX environment to get the next days date based on the date entered by the user of the script. After hard time browsing for this I got a piece of code ...
1
vote
3answers
719 views

Batch file move to directory structure based on filename

I am writing a script to move files into directories based on the filename. Files have yyyyddmm-xxxxxxx.jpg name format. The desired directory structure is in the format 2013/01 Jan/31. I am unable ...
3
votes
2answers
1k views

Need to get the difference between two time in seconds

The following two variables contain the start time and the end time , need to get the difference between these two time in seconds start_time=06:07:25 end_time=07:02:08 Desired Output diff_time= ...
0
votes
1answer
879 views

Getting a date format with grep

I've looked at similar questions and tried most suggestions, but none of them got me anywhere, even though i have a fairly simple task I think :S. I'm fairly new to this whole thing, so I've run out ...
3
votes
2answers
208 views

Bash-script. Shift seconds

Maybe somebody can help me. In bash I don't know how to do that. I need to do a bash-script. At stdin I have .srt file of subtitles in this format: num HH:MM:SS,SSS --> HH:MM:SS,SSS text line 1 ...
2
votes
5answers
3k views

How to append date to backup file

I need to make a backup of a file, and I would like to have a timestamp as part of the name to make it easier to differentiate. How would you inject the current date into a copy command? ...
4
votes
4answers
2k views

Convert Unix timestamp into human-readable format on AIX

I need to convert unix timestamp (number of seconds since 1970, e.g. 1381260225 is Tue Oct 8 19:23:45 GMT 2013) into a standard human-readable format. I could get some answers by googling but those ...
-2
votes
3answers
212 views

make ls display current date and time

I'm new to Linux and I'd like ls to display current date and time as a side effect every time I use ls. How do I go about changing what a command does?
0
votes
2answers
904 views

Sleep until next occurrence of specific time

I need a series of commands or a single command that sleeps until the next occurrence of a specific time like "4:00" occurs. How would I do that? The at command or a cronjob is not a option because ...
2
votes
1answer
88 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
3k 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
950 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
931 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
1k 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
93 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
86 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
3k 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
61 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
138 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
168 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
245 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
298 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
134 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
1k 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
177 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
1k 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
184 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 ...