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

learn more… | top users | synonyms

1
vote
0answers
19 views

Changing the date format of auth.log

I was looking to change the date format in which auth.log logs information. I could not find a way to do it. Is there a method to do this? My system uses rsyslog.
4
votes
3answers
170 views

How do I find seconds since midnight?

Using the date program, how can I calculate the number of seconds since midnight?
1
vote
1answer
10 views

Unzip all non-existing or older files from archive

The behaviour I'd like with unzip is to extract all files, overwriting any that are older than those in the archive, not touching any that are the same age or newer, and to never prompt. The options ...
0
votes
1answer
25 views

Mount changes directory time to 1970

We are developing an embedded Linux system using BusyBox v1.19.4. The system is working fine except for a strange mount issue with time and date. When we create a directory it has the correct time ...
15
votes
1answer
378 views

How to trick a particular command into thinking it is a different date?

How can I execute a command making it believe that is on a different date than system one? For instance, if I have this script: #!/usr/bin/env bash date +"%B %d, %Y" It prints the actual date: ...
1
vote
2answers
578 views

Unable to use date command to change specific date format in Bash shell on OS X terminal

I am using the date -d command to change a specific date format to another. Below is the example used currDate=`Wed 12 Feb 2014` formattedDate=`date -d"${currDate}" +%Y%m%d` echo $formattedDate
2
votes
8answers
2k views

How to generate a year-quarter date from the command line?

I'm interested in outputting a representation of the current year-quarter, as well as the year-quarter for the previous month. If today is 2012 January 1st, I'd like to get 2012q1 and 2011q4 as ...
5
votes
1answer
1k 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
1answer
71 views

mkdir with date function behaves differently in script

I am trying to create a directory with a timestamp. If I type at the prompt mkdir "$(date +%Y-%m-%d_%H%M%S)" I get a directory named with the date as I would like. If I put the same line in a bash ...
6
votes
2answers
159 views

Batch rename image files by age plus add date and variable to filename

The question is completely rewritten due to things learned from the first two answers and comments that I was unaware of when first asking. After a photo shoot I come home with files that look like ...
0
votes
1answer
37 views

change date format and store in variable using awk

I have date in format YYYY-MM-DD in variable 'a'. I want to convert it in format YYYYMMDD and store in variable 'b'. The variable is in an awk variable. How can I do the same ?
4
votes
5answers
2k 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 ...
2
votes
0answers
9 views

change time (date) in or from exif-data

On Change created date from exif data there are great scripts. But what if “Date and Time (original)” are bad in exif-data (because of wrong set time in camera). Is there a solution to change time for ...
4
votes
3answers
39 views

Local Account Creation Date

For compliance purposes there is the need to fetch information regarding local (user and non-user) accounts creation date on UNIX machines. Is there any way (even if it's not the most reliable or ...
2
votes
3answers
45 views

Get the last minute dated lines from list

If I have an input file with a list of users and their dates they were last signed in, how can I select with a sort | awk function the last minute lines? The dates are written in a +%H:%M:%S format. ...
2
votes
1answer
519 views

What is wrong with this code?

I have a script that goes like this: while : do Start_Time=$(date +"%s") MAIN PROGRAM GOES HERE (CROPPED TO SHORTEN THINGS) Run_Time=$(( $(date +"%s") - $Start_Time )) if [[ ...
2
votes
3answers
76 views

Strange formatting of date in bash script

I am working on a script to sort my downloads folder by the date the files were created. This is the script I am using: #!/bin/bash cd ~/Downloads for FILENAME in * do if [[ -f $FILENAME ]]; ...
2
votes
1answer
57 views

How to get modification time for a file (in UNIX TIME!) on AIX?

$ istat TESTFILE.txt Inode 2317 on device 12/7 File Protection: rw------- Owner: 4847(testuser) Group: 346(testuser) Link count: 1 Length 1480 bytes Last updated: Sun ...
4
votes
1answer
460 views

How to understand the unix time format?

How does the Unix time format work? For example, the Unix time for 3:00 PM is: Normal time format <----3:00PM = 1402565420----> Unix Time How can I make it understand the time as 3:00 PM ?
1
vote
2answers
930 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 ...
5
votes
3answers
230 views

How to have command history with timestamps output to the terminal continuously?

I use a simple alias to enable the "tracking" of commands in one or many terminal window(s): alias trackmi='export PROMPT_COMMAND="history -a; $PROMPT_COMMAND"' Then I just tail -f my .bash_history ...
0
votes
2answers
35 views

How can I search filenames which are starting with xy_* and are created/edited today?

Hello I´m currently trying to search for logfiles which are starting with xy_Number and are created/edited today(not last 24 hrs). I tried: find /home/USER/logfilesError/ -maxdepth 1 -type f ...
2
votes
2answers
131 views

How to get previous year and previous month in solaris 8

How to get previous year and previous month in solaris 8? I have tried below command but none of them is correct: date +'%m' -d 'last month' date +'%Y' -d 'last year'
1
vote
2answers
84 views

How to mark dates which are in the past?

From the answers I updated the question: Now, it's: $ date "+%F %H:%M" 2014-06-04 11:26 This is the input: $ cat input.txt <tr><td>2014-04-24 14:01</td><td>2014-06-04 ...
2
votes
5answers
214 views

Listing files greater than particular timestamp in file name?

I have a directory in linux which has a list of log files where log files get auto generated if some job runs. Each log file gets appended with the timestamp like "JobName_TimeStamp" UPDATED: ...
3
votes
2answers
766 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 ...
10
votes
4answers
6k views

How can I avoid “Run fsck manually” messages while allowing experimenting with system time changes?

I'm working with a system where we want to allow users to play around with the date and time if they want, and where reboots may happen arbitrarily. This is fine, except for one thing: if there's a ...
3
votes
2answers
216 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 ...
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 ...
2
votes
1answer
73 views

cut slice of file based on time when lines are written

i have a process running always with logging file could reach up to 5 giga, sometime i have to take slice of this log based on interval of time (usually i used dd). is there any command in linux to ...
14
votes
4answers
10k views

last time file opened

Is it possible to get the time when file was opened last time and sort all files in a directory by those times?
1
vote
3answers
1k views

Highlight the current date in cal

I would like to highlight today's date in the output of the cal command. What is the best way? This is what I have so far: cal -m | grep -C6 --color "$(date +%e)" but it doesn't work for all cases ...
0
votes
3answers
1k 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.
1
vote
3answers
105 views

Convert a date format

I have one problem with my date format. I want to change from one format to the other and vice verse. My date formats are: Format1 : 1/24/2014 Format2 : Jan 24 How can I do this?
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 ...
2
votes
1answer
36 views

convert to epoch and back

I've used the following two perl command lines successfully: perl -e 'use Time::Local; print timelocal(7,51,10,22,3,2014), "\n";' which returns 1398163867, and perl -e 'print ...
1
vote
3answers
69 views

Find records dated before today

how to find record form bellows data having "Last Date" before today's date. i.e : if today date is 09-04-2014 then finding record having "Last Date" before 09-04-2014 - Email ID : abc@domain.com ...
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) ...
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
1answer
40 views

Why date output X-3 instead X-2 days when I am doing arithmetic operations

In one of my script, I need to find a 2 days back date from a given date. I have been using the below without any issue since long time, but it's just the first time I got a error which drilled down ...
1
vote
1answer
131 views

Date calculation in script for notification alerts

I want to create account expiry alerts therefore I need to write a script which could alert me before 1 month of expiry over email. I'm working on Linux. I can get expiry information as 2015-27-03. ...
2
votes
5answers
480 views

Find all files that have been last modified on a specific day - like Monday?

So I want to use find to return a list of all .html files in a given directory that have been last modified on a Monday. How can I do this?
0
votes
3answers
549 views

Change date only for a single non-root user in Linux [duplicate]

Is it possible to change date only for a specific user (non-root) in Linux ? If possible, How to do it ? And it would be great if someone can point out the impact of doing so. EDIT Putting my ...
3
votes
2answers
1k views

How to get 3 minutes future date?

I want to get the date 3 minutes on the future. For example, if "now" is 01-Jan-70 00:00:00 GMT I want to get 01-Jan-80 00:03:00 GMT How should I do it? I'm working with busybox linux.
2
votes
3answers
340 views

What is a standard command for printing a date in RFC-3339 format?

The date command doesn't offer such thing, which is kind of sad since RFC-3339 is the modern, widespread, sane format used everywhere (except in email which is neither modern nor sane). My timezone ...
3
votes
3answers
172 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 ...
3
votes
1answer
112 views

Convert unix time from variable to normal time in AIX

-d doesn't work(date: Not a recognized flag: d): date -d @1141421607 and awk's awk -vNEXTEXECDATUM="$NEXTEXECDATUM" 'BEGIN { print strftime("%c", NEXTEXECDATUM); exit }' doesn't work: "awk: ...
1
vote
1answer
126 views

Using wget to target files within a date range

I'm using wget to download some log files from a remote server. Is it possible to use wget to target files using date ranges (based on the last modified file header) ? For example: wget ...
10
votes
4answers
12k views

How to list files sorted by modification date recursively (no stat command available!)

How can I get the list of all files under current directory along with their modification date and sorted by that date? Now I know how to achieve that with find, stat and sort, but for some weird ...
2
votes
1answer
192 views

solaris awk problems with date and if statements

I have daily files that come in via FTP with incorrect dates in the first column of the file. I have figured out how to deduct one day to derive the correct date and print this to a new file. The main ...