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

learn more… | top users | synonyms

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
112 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
67 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
4k 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
2k 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
74 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
85 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
72 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
2k 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
3k 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. ...
2
votes
2answers
4k 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 ...
4
votes
3answers
1k 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
207 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
110 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
58 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
205 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
829 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
427 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
149 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
1k 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
140 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
392 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
5k 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 ...
1
vote
1answer
743 views

Outputting last modification date to another file?

I'm trying to read the number of lines in a file, and the last modification date of that file (e.g. if it was last modified Jan 18, 2013, it should output 2013-01-18), then append the data to the ...
2
votes
2answers
266 views

Linux date/time - monthly “mongodump”

For MongoDB backups, I want to backup only the newest changes from the previous month instead of everything from the previous month. As part of the query I need to pass to "mongodump", I have to ...
0
votes
1answer
4k views

Convert any Date format in unix

How can I convert any user inputted date into yyyy/mm/dd? For example user can input date in one of the following formats 20120121 , 2012-01-21, 01/21/2012, 01/21/2012 etc. But I need to convert any ...
3
votes
3answers
2k views

Solaris: find the day of last Monday,Tuesday,…Sunday by means of shell script

I'm trying desperatly to find a bash or ksh routine that allows me to find for example the previous Monday,Tuesday,Wednesday,... preceding today's date. Additonal it has to work on plain vanilla ...
3
votes
2answers
1k views

I messed up my system clock in Arch Linux

I installed Arch a couple of days ago. Just realized the date/time were off by a day and one hour. I changed it using timedatectl set-time. Then used hwclock --systohc to set the hardware clock. ...
3
votes
1answer
243 views

Awesome: Incorrect timezone

Typically, I set the timezone of my computer's clock by changing the .bashrc file, appending, say, TZ='America/Los_Angeles'; export TZ such that whenever date is invoked the right time in the right ...
1
vote
1answer
449 views

Help renaming folder according to date

I have the folder "Backup yzT Jan-01-2013". I've made also a script for do a backup everyday. The problem I'm facing is how to rename the folder day by day according to date? Get the new name is ...
0
votes
2answers
202 views

I want to add the above date to each line on a prstat log file

I have a prstat log, as you all know the date and time is recorded on the top of the log file, I would like to add that date and time to the begging of each line until it gets to a new date, then I ...
1
vote
2answers
2k views

How to change the language for date command?

I'm using vnstat together with conky. To show the monthly traffic I'm mixing vnstat and grep to find the month. The command to collect the data is ${execi 3600 vnstat -m -i wlan0 | grep "$(date ...
2
votes
2answers
6k views

Solaris + display file time stamp [year][month][day]

I have Solaris 10 machine I need to verify time stamp of some file in my Solaris machine And to get the following format [year][month][day] Example of working command on Linux ls -l ...
2
votes
3answers
6k views

Appending current date to filename

I'm trying to append the current date to the end of a file name, like what we see in logfiles: TheFile.log.2012-02-11 I have been following this example and applied this to both a Unix and Linux ...
2
votes
1answer
152 views

Why are the timestamps on files so old on my newly installed system?

I installed the Red Hat Enterprise Linux 5.6 on a client system today. If it is of any concern, it's running on the bare metal. After the installation was completed, I did ls -ltr / and it showed a ...
4
votes
2answers
2k views

How do you specify a format for the input to date?

Given a date and time in a format that is not recognized by date, how can I get date to recognize the date and time? For example: $ date -d "09SEP2012:23:58:46" date: invalid date ...
6
votes
4answers
7k views

Appending timestamp stamp along with log file lines

I have a log file and I need to append timestamps to each line as they get added. So I'm looking for script that appends timestamps to each entry in log lines and which could run as a cron job. Could ...
7
votes
2answers
5k views

How to find difference between two timestamps up to milliseconds?

I am new to shell scripting. The heart of my script is to find the difference between two timestamps up to milliseconds. With me I have a file with content of timestamps only as 2012-09-13 ...
4
votes
1answer
142 views

How to show full day name with command of e.g. Jul 16 1991

I found out that date --date 'Jul 16 1991' has an complete output, but I only want the terminal to show the name of the day e.g. Monday. How do I do that?
4
votes
5answers
2k views

Convert formatted dates to seconds since the epoch

I have a file: pablo tty8 Thu Nov 1 12:51:21 2012 still logged in (unknown tty8 Thu Nov 1 12:50:57 2012 - Thu Nov 1 12:51:21 2012 (00:00) pablo tty2 Thu Nov 1 12:50:39 2012 still logged in pablo ...
6
votes
1answer
155 views

locale definition with French republican calendar

I wonder if it is possible to create a locale definition that would make the C library format the dates according to the French republican calendar. I expect then, for example, run `date' and get ...
6
votes
3answers
975 views

Equivalent of date --reference in Solaris

The GNU implementation of the date command has a nice feature to show the date of the last modification of a reference file, and using the +FORMAT parameter it is easy to get the date in any format, ...
3
votes
1answer
5k views

show the year while listing files in the current directory

I am working on a red hat server I want to list the files in a way where the year when each was file created would appear in the Date how is that possible ?
4
votes
2answers
448 views

List files created on Sundays

How do I list/find all the files created on Sundays or Mondays? How do I use the date parameter to display them? Something like : ls -f date + %a or find -type f | date +%A or find -type f ...
5
votes
3answers
8k views

Find files which are created a certain time after or before a particular file was created

I need a shell script which finds files which are created 1 hour before or 1 hour after a particular file (test.txt) was created. If I go with find -newer, that means I'd have to create a temporary ...
3
votes
3answers
13k views

linux + add X days to date and get new virtual date

I have Linux ( RH 5.3) machine I need to add/calculate 10 days plus date so then I will get new date (expiration date)) for example # date Sun Sep 11 07:59:16 IST 2012 So I need to get ...
1
vote
2answers
512 views

Parsing the output of date with sed

I am trying to replace the whitespaces in the output of date with '_' with no success. $date Fri Sep 14 14:10:04 EDT 2012 $ date | sed 's/ /_/' Fri_Sep 14 14:10:24 EDT 2012 As you can see, the ...
12
votes
3answers
6k views

How can I have `date` output the time from a different timezone?

I have a server running with the timezone set to UTC. It seemed like that was generally a good practice (please correct me if I'm wrong). Anyhow, one of the servers I connect to, in order to scp ...
1
vote
2answers
15k views

How can I set the time in Centos so that resetting the OS doesn't revert to its default value?

I have a VPS running on Cent Os 5.8 (x86). There are situations in which we are forced to reset the entire VPS (it hangs and the only way to get it back on is to reset it). When we do so, the time is ...
4
votes
5answers
17k views

Display time stamp in dd/mm/yyyy_hh:mm:ss:ms in Unix or Linux

I need help to display date and time in desired format in Unix/ Linux. My desired format is: dd/mm/yyyy hh:mm:ss:ms in Unix or Linux. I got close using the following command: echo $(date +%x_%r) ...