the "date" tag is used to classify questions about date/calendar/time manipulation, visualisation, conversion... on Unix-like systems.

learn more… | top users | synonyms

1
vote
2answers
32 views

Output both ps and Date on one line, to a file?

I am building a rudimentary logging script, and want to capture the output of ps up 12345 So far I have: DATE2=`date +%Y-%m-%d:%H:%M:%S` echo ${DATE2} >> $filename ps up 12345 --no-headers &...
3
votes
1answer
57 views

how to remove 0 (zero) from the day and month but not from the year (01/09/2012) using in Linux (Redhat)

Using Linux (Redhat) I need some help regarding the a/m request When I use dialog: --calendar to output the date. The format will be dd/mm/yyyy but I need the format to be d/m/yyyy for day and month ...
0
votes
1answer
87 views

Count the number of files with yesterday's date in ls's output

I would like to count the number of files with yesterday's date in ls's output. I tried: yday=$(date --date="yesterday" +"%b%Oe") ls . -ltr | grep $yday | wc -l The problem is that files have dates ...
0
votes
1answer
65 views

How to set date with Epoch format

I want to set date from a seconds since epoch value, for instance I want to set date with input value 1452053571. I read through date -help but not found anything. Is there any parameters to do it?
3
votes
2answers
147 views

Find all files modified around a known one

An installer which isn't really clean (Adobe Acrobat Reader DC) installed on my Unix (Mac OS X) a lot of files in different places. I have a reference file Application which I am pretty sure was ...
0
votes
1answer
103 views

Setting time and date without using NTP

I have a "windriver" linux based Wimax ASN, and when ever I login, I find the date and time is wrong (example: "15 jul 2010"). Whenever I set both the date and time with the date command, or the ...
3
votes
3answers
22 views

jump to current day's directory in a date based directory hierachy?

I have a pretty standard directory higherachy, year, month, date, for log files. If I want to go to todays logs I have to type cd logs/2015/12/16/ By itself this wouldn't be bad, but since I ...
3
votes
1answer
56 views

How to I convert month name to number in BSD date?

I have found solutions for GNU date, but not for BSD date. I would rather not make an if, etc. before I know if there's a built in way.
1
vote
1answer
106 views

How to extract date and calculate if it is within “x” days from today?

Currently I have file with structure as Foo Sign: blah SubFoo Sign: blah BarDate: 2017-11-31 Foo Sign: blah BarDate: Never Foo Sign: blah BarDate: 2016-12-20 Foo Sign: blah ...
3
votes
2answers
62 views

Date change format in unix

I am passing date as variable in function. I want to convert that date in different format. Example DT=2015-12-08 Want to convert DT to 08-dec-2015 in Unix.
0
votes
1answer
25 views

How to see the lines whose date column is less than x day from today

My file ID=29524 02/12/2015,23:59:34,'PAt, 0, ID=29628 02/12/2015,23:59:37,'PAb, 1.9, ID=30816 03/12/2015,00:00:20,'PAc, 4.15, I would like to print files with X days less than from today. My try ...
1
vote
2answers
212 views

How to get yesterday date and stored into one variable

I am having a log file where I need to grep based on yesterday date. How to get the yesterday date. The time stamp in the log file is formatted as: Wed Sep 23 for two digit Wed Dec 1 for one digit ...
0
votes
1answer
135 views

Can I see always time in console?

I would like to set the Linux console such that it shows the current time always in console's upper right corner. Is that possible to do? Or is it wise to do if one can never be sure if the cursor is ...
1
vote
1answer
38 views

date: Getting next certain hour

I want to get a date-time string in the future, for example I always want to get the next time of 9:00 am. I know the string formats like "tomorrow" or "next day" to get a certain date-time string. ...
0
votes
5answers
111 views

Bash:decrementing american date by 1 day mmddyyyy

To simplify the problem, lets say I have variable: dat="10152015" (representing 15th October 2015) the result for dat should be 10142015 Note that I am not using today's date. What I have problem ...
0
votes
1answer
81 views

Convert date strings like 20 July 2017 to epoch and compare in Linux

I am using ksh, and have a text file with several lines of following content. I am trying to compare the date part to current date and find the difference in days and then output the "Server" and "...
0
votes
1answer
67 views

How to find files that were most recently created on file system?

I am trying to track the completion of a silent installer by detecting the presence of the last file created by it, but in order to do that I need to find out which file that is. Is there any way to ...
0
votes
2answers
59 views

Set yesterday Date in script special for Monday

I am writing a script a check whether exist a backup file every morning Monday to Friday. These backup file is saved in the end of everyday from Monday to Friday only named as 02_10_15 There is ...
1
vote
1answer
31 views

Extract entries from a file ranging from one date to another

There is a file which has entries with the first and second field as date and time in the following manner : 2015/10/14 00:33:37. The file has 100,000+ lines and is constantly updated. Entries in the ...
1
vote
4answers
342 views

How to get the last five business days in a Unix shell script using a `for` loop?

The following script: BUSSINESS_DATE=`date -d "-2 day" +"%Y%m%d"` for (( c=0; c<5 ; c++ )) do WEEKDAY=`date --date="$BUSINESS_DATE -$c day" +%w` if [ $WEEKDAY == "0" ] then ...
0
votes
2answers
81 views

Date format for variable

I need to write a variable with "date" function and I need that the format is yyyymmdd (i.e. 20151031). Also I would remove a day (i.e. 20151031 becomes 20151030) I would use bash. Thanks!
0
votes
1answer
156 views

Execute a command every minute forever using 'date'

I'm looking for a way (bash script or other) to make a command run every minute using date - I've been looking around for similar solutions but they all suggest either cron or watch but what I want to ...
0
votes
2answers
55 views

Get the first column of date linux

When I run date on my linux I get Sat Oct 31 11:53:22 BRST 2015. I want to get only Sat. How do I do that? So far I think I should use the code below but it does not work: date | printf $1
3
votes
1answer
176 views

Why does “date” show different times in root and user?

Using dpkg-reconfigure tzdata I have set my timezone to CST, but for non root users the system persists in using UTC time. pi@raspberry ~ $ date Wed Oct 28 18:14:08 UTC 2015 root@raspberrypi:/home/...
0
votes
1answer
372 views

I'm trying to compile alsa-driver-RTv5.18 but get date-time error for gcc 4.9.2

/home/user/Downloads/Rt-Linux-HDaudio-5.18/alsa-driver-RTv5.18/alsa/acore/info.c:1065:22: error: macro "__DATE__" might prevent reproducible builds [-Werror=date-time] "Compiled on " __DATE__ " for ...
0
votes
0answers
74 views

Reset time / date to current time-zone using timedatectl preferably, or date

As the title says, I'm looking to reset the current system time to the selected time-zone using the timedatectl preferably, or date command. This is on the CentOS 7 OS, hence the timedatectl ...
0
votes
1answer
71 views

Error in 'date -d' command

Hmmm... Right now (Sat Oct 24 00:36:56 CDT 2015) on my Arch Linux system there appears to be a problem with the date command: $ date -d "+8 days" "+%A %d %B %Y" Sunday 01 November 2015 $ date -d "+9 ...
5
votes
3answers
434 views

Unix epoch in milliseconds

I'm prepending the Unix epoch with "nanosecond" precision into output of my command as below: $ command | while read line; do d=`date +%s%N`; echo $d $line; done > file I looked around to find ...
5
votes
2answers
324 views

Datecalc equivalent for Linux

Am using a script in ksh to get a date 91 days prior to today using datecalc on a Solaris 10 server. What would be the equivalent to this in Linux ? month=`datecalc -a $(date +"%Y %m %d") - 1 |awk {'...
3
votes
2answers
192 views

How can I check whether $date1 is before $date2 in shell?

date1=$1 date2=$2 How can I check whether $date1 is before $date2? Both dates are in DD/MM/YY format i.e. 01/01/15.
1
vote
2answers
227 views

Compare two times in HH:MM:SS format - ksh

Is it possible to compare two time (24-hour format)? What I need is to just check if the first time is earlier than the second time. Example: $ ./script.ksh 09:30:15 13:00:34 okay $ ./script.ksh 05:...
1
vote
1answer
531 views

invalid date error for %m%d%Y format

I want to convert a String in %m%d%Y format to date. But, getting invalid date error as shown below: bash-4.1$ date -d '10042015' +"%m%d%Y" date: invalid date `10042015' How to fix it?
1
vote
4answers
3k views

check if date argument is in yyyy-mm-dd format [closed]

Is there a way to check if a date argument is in the correct format (YYYY-MM-DD)? I got this from the web but it doesn't work for me: date "+%Y-%m-%d" -d "2015-10-11" > /dev/null 2>&1 ...
1
vote
3answers
366 views

Excluding specific date and time in cronjob

I am trying to schedule a cron job where the requirement is the job has to run every day, every month and every min and every hour EXCEPT 2nd and 4th sunday of every month from 1 to 3 AM. Is there a ...
1
vote
1answer
190 views

BASH AWK Script add days to fixed date

My task is to export data from a database with the UNLOAD TO statement in dbaccess and convert it into a file, that can be inserted into a similar database. Now the problem: The old database (let's ...
0
votes
2answers
116 views

Subtract two dates using Shell Scripting [duplicate]

How can I subtract two dates in epoch format using Shell Scripting. I want the output in Months, Days, Hours format. Also It should work even for more than 12 months ( as I came across few which were ...
2
votes
4answers
53 views

how to get a different time-clock on CLI apart from your time-zone?

Is there a way to invoke or know a different clock or time on the CLI. The thing is I'm on UTC+5:30 time but at times need to know time in different time-zones. If there is a CLI way in which this can ...
3
votes
2answers
135 views

Script to compare job date to today's date and only output today's failures

Full disclosure: We do not have full access to the autosys database, so our only option for keeping history is to create an Oracle and use the autorep command to output data. We have Linux servers ...
-2
votes
1answer
42 views

How can I write a bash script that tells me how many hours there are from 23:43 to 02:10?

How can I calculate with hours and minutes in bash? For example say I want to write a script that takes two timestamps and tells me how many hours there are in between them, how can I do that? $ ...
3
votes
2answers
318 views

How to convert date from “Oct 01 20:00” to “Oct 1 20:00” format (space padded)?

Here Oct 01 has to be printed as Oct 1 i.e without 0. I need two spaces between Oct and 1 i.e like Oct 1.
5
votes
1answer
112 views

When is next Monday?

On my home computer (Xubuntu 14.04), I have zev@home:~$ date +%F 2015-10-05 zev@home:~$ date +%F -d "next Monday" 2015-10-12 whereas at work (Red Hat 5.11), I have zev@work:~$ date +%F 2015-10-...
2
votes
1answer
360 views

Why does `date` show UTC time, even with a different timezone set?

I'm running Raspbian on a Pi 2, and I've run into a bit of a pickle. While I'm not sure this behavior was different previously, running date outputs the same time as date -u, despite my timezone being ...
1
vote
2answers
94 views

Compare two dates with different format [closed]

I have two files, each file contain a different date's format as below: File1: 2014-NOV-0620:59:59 File2: 2014-12-31 How can I compare those two dates in awk?
3
votes
1answer
160 views

Automatically synchronization between system time and hardware clock time

I'm working with a Linux embedded board. It uses Linux kernel v2.6.37 with an external I2C RTC cbc34803. I've successfully intergrated the RTC hardware. It works correctly except the problem ...
1
vote
2answers
247 views

How do I get the date from two weeks ago using Solaris' date?

Linux uses: date -d "2 weeks ago" +%b which is equivalent in Solaris?, I searched online, but nothing.
2
votes
1answer
358 views

How to get the current date and time in YYYYMMDDHHMMSS format in ksh88?

I am new to Unix and in need of some urgent help. I looked around a lot first to find how to get date difference (in a 1 or 2 liner code). But none worked for me. My requirement is to get difference ...
5
votes
3answers
2k views

How to format date output with spaces as variable in script?

I want to make the date command with nice formatting like this: $ date +"%Y-%m-%d %H:%M:%S" 2015-09-17 16:51:58 But I want to save this in variable, so I could call from script like this: echo "$(...
-1
votes
2answers
136 views

Script with input date, output day

I want to write a bash script that reads a keyboard input (date dd:mm:yy), stores it in a variable then echoes back the Day it corresponds to, ie Input : 03/08/2015 Output : Wednesday I'm having ...
-1
votes
1answer
155 views

How to get last quarter in Bash Script

I have a script that gets the proper quarter but I need to get the (quarter - 1) quarter=$(($(($((10#$(date -d $year$month$day +%m))) - 1)) / 3 + 1)) Currently this returns 3, I need it to return 2....
13
votes
9answers
16k views

How to chain the commands 'date -d @xxxxxx' and 'find ./'?

I have directories whose names are timestamps, given in milliseconds since 1970-01-01: 1439715011728 1439793321429 1439879712214 . . And I need an output like: 1442039711 Sat Sep 12 08:35:11 ...