Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [date]

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

8
votes
5answers
55k 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 ...
1
vote
3answers
3k views

How to know last Sunday of month

i try writing script on ESXI and i need add "if last Sunday of month". I try date -d @$(( $(date -d $(date -d @$(( $(date +%s) + 2678400 )) +%Y%m01) +%s) - 604800 )) +%d It can not work, but it ...
3
votes
1answer
139 views

Why does my date output have “STD” as the time zone?

When I run date on my Ubuntu under WSL, it prints: Wed May 15 19:33:37 STD 2019 Why does this have the string STD in it? I can't find a timezone online with the abbreviation STD (for example here) ...
0
votes
1answer
147 views

linux unix posix EPOCH time format

I have some audit logs with a date stamp of the format 1532400673.760:2358773 what are the numbers after . and after : represent? using a website epoch converter 1532400673 converts to GMT: Tuesday,...
0
votes
2answers
641 views

Shell output question

What is the output of date -u +%W$(uname)|sha256sum|sed 's/\W//g' (on Arch Linux if it matters)? How do I find that out?
-1
votes
0answers
29 views

HP-UNIX How to find the date time difference?

In HP-UNIX how to find the date time difference ? Start time: 28-APR-2019 21:36:01 End time : 29-APR-2019 00:36:04 ---------------------- Difference is ---------------...
2
votes
1answer
63 views

How to stop opening a file in LibreOffice from changing folder's Date Modified

Opening a file with filename foo with LibreOffice creates, at least on my system (Debian Jessie, Openbox, no Desktop Environment, Thunar) a file named .~lock.foo#, apparently as a means of flagging ...
1
vote
1answer
43 views

What timezone does the `at` command use?

I've searched in the man pages for the at command there are no mentions of timezone or tz. There is this: The exact definition of the time specification can be found in  /usr/share/doc/at-3.1.10/...
0
votes
1answer
238 views

How to set dd/mm/yy for command-prompt in zsh?

I am on zsh (not using oh-my-zsh) and want to have a custom command prompt. Currently it just gives the hostname and % as command prompt - [code] think-debian% hostname think-debian [/code] what ...
1
vote
1answer
35 views

bash next month error

Running into errors. I am trying to get the next month when a user sends a date in. D="2019/12/01"; D=$(date -d "$D"); echo "Current Date = $D"; prints Current Date = Sun Dec 1 00:00:00 EST 2019 ...
0
votes
1answer
9 views

ausearch how to specify both time and date

I can run ausearch based on time: sudo ausearch --start '16:48:07' or date: sudo ausearch --start '05/07/2019' but not both: > sudo ausearch --start '05/07/2019 16:48:07' Invalid start time (...
7
votes
3answers
442 views

How can I list files in reverse time order by a command and pass them as arguments to another command?

I have a program which takes in some files as arguments in one command line. I would like to invoke it with all the files in a directory listed in reverse time order. For example: I have following ...
33
votes
10answers
74k 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?
2
votes
1answer
11k views

Subtract 7 days from today's date

Here is my script. I need to subtract 7 days from today's date and use it in a file name. I am using a Mac. #/bin/bash DATE=$(date -d "-7 days") echo $DATE When I run this .sh script, I get this: $ ...
0
votes
1answer
33 views

Get Next working day using variable

I want to extract the next working day from the date generated by the script and assigned to variable last_day Let's say variable last_day has a value last_day=20190426 i want to get next_day=2019-04-...
3
votes
2answers
176 views

Deleting files older than 30 days based on filename as date

If I have a folder of files with their filenames as the date they were created: 2019_04_30.txt 2019_04_15.txt 2019_04_10.txt 2019_02_20.txt 2019_01_05.txt How would I compare the files names against ...
1
vote
4answers
68 views

Delete files - Keep newest based on filename pattern

I have a directory with a lot of files. Each file have the same pattern <id>_data_<date>.csv. What i want to do is to delete all files but to keep the newest per <id>. Example ...
78
votes
13answers
177k views

Quickly calculate date differences

I often want to make some quick date calculations, such as: What is the difference between these two dates? What is the date n weeks after this other date? I usually open a calendar and count the ...
0
votes
2answers
25 views

List lastest modified or newly created files in linux

How to list modified or newly created files or directories in linux. So that I can trigger another command or shell script for another task. for eg. A file a.txt and test.txt are modified and I ...
1
vote
1answer
62 views

writing a script that finds incorrect files, and corrects them through stdout

I am currently using UNIX bash, and I want to write shell script that allows me to correct the date entry by using information in a file's pathname. Background: I previously had 200 files that were ...
0
votes
3answers
746 views

Hours and Minutes addition in Solaris

I work in a solaris server and the date -d option is not there. No gdate as well. Here's what I have which works in Linux: date -d "$hr:$mi $duration minutes" +'%H%M' where $hr and $mi are hours ...
0
votes
1answer
13 views

Builroot date is wrong

When I flash a buildroot image for the raspberrypi3 using the date command will give me 1970-01-01. I have to manuel reset that every time. What would be the correct way to handle this, should I ...
74
votes
6answers
354k views

Linux: set date through command line

How to change the system date in Linux ? I want to change: Only Year Only Month Only Date Any combination of above three
1
vote
2answers
3k views

Display all the dates in week numbers in UNIX [closed]

I know the command to get the week number of a date is date +%W Output: 03 Now, is there a way of giving a week number it will display all the dates in that week? Or should I write a script? Eg: ...
3
votes
2answers
601 views

How to delete files created between two times?

I have a folder where I backup my databases to and I want to delete all backups created between 11 am and 3 pm and it doesn't matter what day it is -- this is the catch! I found this command to be ...
30
votes
6answers
33k 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 ...
0
votes
1answer
1k views

tail-ing a filename that is a date [duplicate]

I am creating a logfile from kermit named the current date (which is in the format of DD MMM YYYY - which can not be changed AFAIK), and using the file name as today's date. I then have a Bash script ...
3
votes
1answer
3k 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 ...
1
vote
3answers
391 views

Checking whether a date is within the next week

Trying to create a script for automatic SSL renewal with LetsEncrypt. Daily script begins with checking when SSL expiry is: response="$(openssl x509 -enddate -noout -in ~/letsencrypt/www.mydomain....
0
votes
3answers
62 views

display all patches/packages installed in the last month

I would like display all the installed packages of last month with the rpm -qa --last command which outputs in this format: libgcc-4.4.7-17.el6.x86_64 Tue 01 Nov 2016 12:55:21 PM ...
5
votes
7answers
1k views

How to remove a part of a column using awk

I have this : 2018:01:02-23:52:48 2018:01:02-23:52:48 2018:01:02-23:52:48 2018:01:03-09:26:20 2018:01:03-09:26:20 I want to keep the date, but not the hour in order to sort the number of messages ...
0
votes
0answers
17 views

Rewrite files last modified date

I have a folder of contents which I wish to archive. Each file has a different last modified date. Is there a way to change the last modified date of all the files to a specific one from the past? I ...
0
votes
1answer
2k views

How to run commands on a variable containing a date?

I need to be able to take a date in the format of "MM/DD/YY" and change it back into the default date format (Fri Oct 31 17:23:07 CDT 2014). This is driving me crazy. The code below may look ...
0
votes
3answers
43 views

Grab the oldest 100 files out of thousands and zip them up but also create a listing of those files that I can cat out later

I was wondering if there is a way to grab the oldest 100 files from a directory that has a 1000 or more in it with the same prefix (cdr12345.csz, cdr32342.csv, cdr 98876.csv, etc..) and list the names ...
2
votes
2answers
1k views

Padding day / time values to ensure 3 digit length

I have a script which renders timestamps in the format YYYY'DDD'TTT where Y = year, D = day out of 365 and T = time in 1000th's of the day: #!/bin/bash clear s=$(($(date +"%H*3600+%M*60+%S"))) t=$(($...
0
votes
1answer
49 views

Rewrite last modified date when unzipping archive

Is there a way to rewrite the last modified date of all the files inside a .zip file to the date of extraction? Basically, whenever someone unzips the archive, the last modified date of all files is ...
4
votes
3answers
6k views

Add 30 days in date

Using bash or mysql , how can I add 30 days in user expiry table? Example I have DB name USERS and table expiry like this: USERNAME EXPIRATION JOHN 2015-09-26 I want the command to take ...
1
vote
2answers
86 views

script with date work on Linux but not on AIX

I wrote a script to that works fine on Linux but fails on AIX 7.2. My script uses the command date with -d. The purpose of this script is to get the last day that is not a Saturday, Sunday or a ...
169
votes
12answers
244k views

How do I convert an epoch timestamp to a human readable format on the cli?

How do I convert an epoch timestamp to a human readable format on the cli? I think there's a way to do it with date but the syntax eludes me (other ways welcome).
0
votes
1answer
22 views

Add log filename with minus 3 day in crontab

I want to set my log file name into crontab with date - day, not current_date. I've already success for current date like this: 00 02 * * * bash run_myscript.sh > /logs_myscript_`date "+\%Y\%m\%d"...
0
votes
4answers
2k views

Give previous date as argument to shell script

I need to execute the script by passing previous date as command line argument. It must be automated. So, how can i pass the previous date to the script? For example: sh processFile.sh previousdate ...
6
votes
1answer
240 views

Escape a mm/dd/YY backup date in a file name

I have been trying to: cp file.csv file.$(date +%D).csv But it fails because the filenames is: file.03/27/19.csv with the slash of separate directories. And I have been trying again to: cp file....
1
vote
6answers
57 views

Get list of folders that are after certain number

I have a folder which subfolder naming convention is like yyyymm for e.g. 200801, 200803 etc. I want to list down folder after 201412 via command line means to upload to S3. Is there a way to do it?
2
votes
1answer
155 views

How to read dd/mm/yyyy date string in date -d UNIX command?

I am trying to dynamically convert one column in text file containing date in dd/mm/yyyy hh:mm:ss format to yy-mm-dd hh:mm:ss. Following command is working but giving output in yy-dd-mm and NOT yy-mm-...
0
votes
0answers
19 views

Buildroot date is set to Jan 1, 1970

why does buildroot automatically set the date in the title. And how do I fix that? Or do I have to make a script to manually set that?
0
votes
5answers
185 views

Get date of Monday two weeks ago from particular date using GNU date

I understand the command date -d 'last-monday - 14 days' +%Y%m%d will print the Monday two weeks ago from "Today's date". I need a way to test this for different dates and see the result. Almost like ...
7
votes
1answer
561 views

Which service provides time-sync.target in systemd?

How can I recognize which service provides time-sync.target in systemd? Is it configurable or is it hardcoded in systemd? How can I configure my custom time-sync daemon/service to provide this target?
1
vote
1answer
39 views

Calculate difference in numbers and save in colon-separated time format with bash script

I have a tab-separated file, e.g., 0018803 01 1710 2050 002571 0018951 01 1934 2525 003277 0019362 02 2404 2415 002829 0019392 01 2621 2820 001924 0019542 01 ...
9
votes
1answer
614 views

Bash - date, working around the 2038 bug on 32bit LINUX system

I wrote a little bash script that made me stumble across the "Year 2038 Bug". I did not know about this problem before and I just dare on posting the --debug output I got from date when my script ...
1
vote
0answers
15 views

Timestamp retrived with `date -r file` does not fit the time order of commands [duplicate]

I was playing around with the command date to create timestamps and profile the execution of a script. I decided to set four of them, named t1 through t4. For t2 I created an empty file whose last ...