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.

1
vote
0answers
34 views

Is it possible to write “time” to bash history? [duplicate]

I love to know how long my CLI commands take so I often preceded them with time - sometimes I forget. Also I don't keep a record of long running commands so can't see if they vary over time. My bash ...
1
vote
2answers
31 views

Bash command to rename files and convert datestamp from 'dd[st/nd/rd/th] mmm yyyy' to 'yyyymmdd'?

Is there a simple bash command that will match the date string in a filename like this... File Name 20th May 2019 descr.txt (File Name and descr are strings of variable length) ...and convert it to a ...
0
votes
1answer
16 views

Range of dates with minutes

I am trying to create a series of dates from 01/01/2010 to 01/02/2010 with the minutes at uneven distances, like so: 2010 1 1 00 00 00 2010 1 1 00 20 00 2010 1 1 00 30 00 2010 1 1 ...
3
votes
1answer
140 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) ...
-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 ---------------...
1
vote
1answer
44 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/...
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 (...
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
69 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 ...
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
68 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 ...
6
votes
3answers
459 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 ...
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 ...
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
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 ...
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 ...
0
votes
1answer
23 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"...
6
votes
1answer
241 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
174 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
206 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 ...
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 ...
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 ...
0
votes
3answers
74 views

Zipping the 10 most recent files

Basically my requirement is to find 10 latest logs and compress it into zip. I have tried command ls -Lt | head -10 | zip log.zip *.log, but output is not matched.
1
vote
1answer
80 views

Checking for invalid date in bash script

I am checking for a valid date scrpt.bash test 2019-05-03 date -d $2 2>: 1>:; c=$? If $c is 1 then the date is invalid. If I enter 2019-05-03 I will get a 0 which is correct. If i enter 2019-...
0
votes
1answer
51 views

Creating a for loop with find -exec and while

I am trying to make this script that loops through video files created between hours 00 and 12, convert them with ffmpeg and then remove them. The script works in terms of finding the files and ...
0
votes
2answers
40 views

Manually set time overwritten without a time sync active (in a VM)

I'm trying to set a fake time on Ubuntu 18.04 (systemd 237) for purposes of testing an execution of a monthly periodic task. This is running on a virtual machine (virtualbox with guest additions). ...
0
votes
1answer
25 views

How to add both date and space to a filename [duplicate]

If I execute touch $(date '+%F %T'), I expect one file whose filename comprises the date and time to be created; but instead two files are created: one whose name is the date, and the other whose name ...
0
votes
2answers
37 views

Format date output minutes as the fraction of an hour

How do you format the date time output so that 11:30 is printed as 11.5?
1
vote
2answers
163 views

How to search for a specific string in files from a specific date?

How can I search for a specific string in files from a specific date? For example, I have 3 files named 'a1' dated: 20 Feb, 'a2' dated 21 Feb, 'a3' dated 22 Feb. Now I want to search for a certain ...
0
votes
0answers
88 views

SFTP the latest file

I need to sftp to a remote server, find the latest file on the server, download the file, and rename the file so it's not used again. I have no control over the file naming convention, so I need to ...
1
vote
2answers
137 views

Embedded Linux: setting the time without NTP

Working on a embedded Linux device built using yocto that is pulling a date via uart from another device with a satellite connection. By the time we have access to this date, we are well into a fully ...
0
votes
1answer
55 views

Daylight saving in Debian 9

I would like to know how to enable Daylight saving support for Debian 9 with LXDE. My timezone is set to Europe/Rome. However my clock is one hour ahead and - considering Daylight saving - it shouldn'...
0
votes
1answer
52 views

How to schedule cron jobs in linux?

I have script files. .file I need to run only on the first day of the every month. How can I do this with my cron job? 52 07 * * * bash '/home/linux/tanu/cat.sh'
1
vote
3answers
43 views

Sort date in format “date +%a %b %d %T %Y”

I want to Sort the data in a file considering the date column (last column in the sample data). I have tried some commands but didn't get succeeded. Sample data: Beendet|48149|1550804401|STR|Fri ...
1
vote
2answers
658 views

How to compare two dates in bash script?

I am trying to compare todays date with the last modified date from a file. DATE=$(date +"%F") LASTMOD=$(stat $i -c %y); LASTMOD_DATE=$(cut -d' ' -f1 <<<"$LASTMOD") if [ "$LASTMOD_DATE" -...
0
votes
1answer
47 views

conversion of date into seconds in unix

I have a requirement where I will be give the time in below format 2019-02-08T19:24:30.220Z by this I need to output number of days between the given date and present date. given date = 2019-02-...
-1
votes
1answer
48 views

How to switch to the last added folder in that particular folder in S3 bucket

I have a **S3 bucket in which starting of every month ... will be added. And in the month lder daily **new files will be added .
0
votes
1answer
191 views

date addition in bash doesn't work in docker

I have followed examples on numerous stack exchange websites and various other tutorial websites on how to do date math. I have tried linux (on containers) I get the exact same error: $ docker run -...
0
votes
2answers
78 views

Bash-Script: rename files in folder order by file-date

I want to rename files in order of file-date; from example: file_1.pdf file_2.pdf to: file_1_ONE.pdf file_2._TWO.pdf The script must rename the first file to "ONE" ordered by file-date.
15
votes
5answers
2k views

Subtract time using date and bash

All the other questions on the SE network deal with scenarios where either the date is assumed to be now (Q) or where only a date is specified (Q). What I want to do is supply a date and time, and ...
0
votes
0answers
42 views

Find the difference between 2 dates [duplicate]

Job1 07/09/2018 22:40:57 01/20/2019 11:48:52 Job2 11/28/2018 19:23:49 01/20/2019 05:29:49 Job3 10/10/2018 01:51:52 01/19/2019 23:08:13 Job4 12/08/2018 20:51:34 01/19/2019 22:04:26 Job5 12/...
1
vote
1answer
28 views

collect logs from bash each 24 hours [closed]

my idea is to collect logs each 24 hours ,mail it and flush them after that i wrote some scatch for example 1.var/log/auth {some info} 2.var/log/something.log {some info} list="$(find /var/log -...
2
votes
2answers
285 views

date command in busybox not accepting formatted input date

I want to set the date using busybox's date command (BusyBox v1.21.0). My custom date to which I want to set the computer is of this form: Tue, 15 Jan 2019 10:46:13 GMT What my date command is ...
0
votes
1answer
91 views

Set date on embedded linux with limited busybox (no ntp)

I am trying to automatically set a date after boot on an embeddd linux with busybox ( I dont have a RTC). I also dont have ntp command in busybox, nor curl. My wget is very limited too, and I cant ...
0
votes
1answer
446 views

date: invalid date trying to set linux date in specific format

i try to set linux date & time in specific format but it keep giving me error Example : date "+%d-%m-%C%y %H:%M:%S" -d "19-01-2017 00:05:01" or date +"%d-%m-%C%y %H:%M:%S" -d "19-01-2017 00:05:...
2
votes
1answer
39 views

Improving performance of Script Using find and exec [closed]

I have a script that iterates through a given directory and automatically compresses those that do not contain at least one file used in less than 30 days. Now, I am wondering if I could improve ...