Questions tagged [date]

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

Filter by
Sorted by
Tagged with
2
votes
2answers
164 views

`date` command doesn't have an option for ISO-8601 week format input?

I occasionally use the date command to check the current or a future date's week number based on the ISO-8601 week-date calendar. To do this I simply use: date +%V to check the current ISO week number ...
1
vote
1answer
22 views

How to get Order_date last month last day in UNIX

We use to run shell scripts through Control-M and shells script accepts execution date as input parameter and script should calculate last month's last day whatever order date we run. I am trying to ...
0
votes
1answer
33 views

Modification Date on EXT4 files marked as Nov 29 1979

I am running Linux Mint 20.2 64 bit Cinnamon and these are FLAC files that are failing an integrity test. The files seem to play fine. Could this be because the Modification date is wrong. The date ...
2
votes
5answers
79 views

Converting date of format '%d/%m/%Y %H:%M' into seconds

I'm getting the following error date: invalid date '23/07/2021 14:44' when running this code start="23/07/2021 14:44" startSec=`date +%s -d "${start}"` I also tried start="...
5
votes
6answers
1k views

Convert a date from DD-MM-YYYY to YYYY-MM-DD format in bash LINUX

Scenario: I am fetching a date value from a file into a variable and it is in DD-MM-YYYY format by default. I have to substract this date from system date. Subtraction is giving incorrect result if I ...
1
vote
0answers
27 views

How to filter for only unique errors in multiple logs using grep?

I am trying to use the following pattern on Ubuntu: grep -Eri "warning|error|critical|severe|fatal" --color=auto to find relevant errors in many different .log files recursively in /var/log ...
0
votes
1answer
22 views

How can I get the current time as an LDAP timestamp in Unix?

I want to be able to generate an ActiveDirectory LDAP timestamp in Unix for some tests I need to run. Active Directory stores date/time values as the number of 100-nanosecond intervals that have ...
2
votes
1answer
92 views

How to get a formatted date string's format?

I wrote a shell script that manipulates dates; it gets one or more date strings from the arguments and then outputs a result. Say, $ datecalc 06/27/2021 01/01/2000 05/10/2005 This script uses the ...
0
votes
3answers
64 views

Cron public IP to log file [duplicate]

I want to log my public ip to a file using cron. Something like this: 2021-05-17T01:11:46 99.99.99.99 2021-05-17T01:12:46 99.99.99.99 2021-05-17T01:13:46 99.99.99.99 Here's what I've cobbled together:...
1
vote
2answers
68 views

Convert year month to different format

I have year and month in the format YYMM and I want to convert them to YYYY Month format. The year is always 2000 and later. So for example; 1908 becomes 2019 Aug 1904 becomes 2019 Apr 2012 becomes ...
0
votes
0answers
24 views

Whats the Source and Precision of the “Date”-Clock

I need to verify the precision of a PHC clock on my Linuxboard. Therefor I want/need a clock, wich is as precise as possible. My first guess was to simply use the timestamps i get using the Date ...
2
votes
2answers
156 views

Can't specify file creation date

I would like to automate the creation of some files so I created a script. I want also to specify the creation date of those files. In a terminal for example, to create a file.txt with creation date ...
0
votes
2answers
49 views

save the output into variable

I am a new learner in this field. I want to subtract few seconds from date_time. I used this code to extract data and then subtract the seconds. BUT I can not save this output into a variable. Could ...
0
votes
3answers
29 views

Numbering a bunch of files according to the date modified timestamp?

So I downloaded a bunch of documents in chronological order, but I have to copy and edit them, which would change the date modified. I would like to prefix them with a number (001_, 002_...) in the ...
0
votes
2answers
72 views

date validation for a custom format in shell

i am writing a generic script for the custom format date validation . here is the script dateformat=$1 d=$2 date "+$dateformat" -d "$d" > /dev/null 2>&1 if [ $? != 0 ] ...
0
votes
2answers
42 views

Using `date` with the `-d` / `--date=` option

I want to use date to calculate some future "alarm times" for the realtime clock on my Raspberry Pi. These "alarm times" will be used to "wake" the RPi. The scheme I ...
3
votes
2answers
109 views

command-line tool for converting/formatting time

Is there a command-line tool to convert/format time? (I mean time, not date!) Here is what I was expecting: $ timeconverter --format '%s' 1h 3600 $ timeconverter --format '%h:%m:%s' 3665s 1:01:05 $ ...
1
vote
1answer
49 views

Find files created during a certain hour of any day

I understand that it is possible to use find to locate files that were created during a specified range of time. For example, the following should output a list of all the files created (inode change ...
12
votes
3answers
1k views

Why does the `-` (minus) interpretation of GNU date differs from the intuitive one, when a date is specified?

If I subtract a time amount from the current date, GNU date works intuitively: date '+%F %R'; date '+%F %R' --date='- 1 hour' 2021-04-19 15:35 2021-04-19 14:35 However, when I use a date as operand, ...
-2
votes
2answers
79 views

How to check the number of day of month?

I want a bash script to check if today is 15th of the current month? if [ $dayOfMonth == 15 ] then echo "15th day of month fi
0
votes
2answers
37 views

How to use sed command regexp group to pass data from group to section $()

I want to change date in mail.log to timestamp format using sed command. There is a problem how to pass \1 from group to date command inside $() ? sed -E "s/(^.{15})/$(date -d "\1" &...
0
votes
1answer
44 views

How to get my guest to keep the correct time and date?

I'm running windows 10 inside gnome boxes (on fedora) which, while kinda slow, works well enough. However, after closing and reopening boxes, it appears that windows just continues where I left off. ...
1
vote
2answers
127 views

Date and time zone offset not working correctly

I'm facing a strange behavior of date command when using time zone offset on Solaris. >echo $TZ MET >date Wed Mar 31 11:41:45 MEST 2021 >TZ=MET+24 date Tue Mar 30 09:42:06 MET 2021 >TZ=...
0
votes
4answers
280 views

what timedate value is always greater than any timedate?

What timedate value is always greater than any timedate? In a script, I want to provide an argument to variable duration so that the loop will run forever until I kill the process: # `duration` has a ...
0
votes
1answer
20 views

Bash-Script: stop/abord if is last Sunday in March or October?

How can I stop/abort a bash-script when: is last Sunday in March? OR is last Sunday in October? Both should be checked here and if so the bash script should be stopped/aborted. Thanks in advance. ...
2
votes
0answers
24 views

Making the locale time format more compact

dmesg -T gives human readable time format, and I want to make it more compact, from this [Пт мар 12 09:18:54 2021] wlan0: associated to this [12.03.21 09:18:54] wlan0: associated I'm using ru_RU.UTF-...
1
vote
1answer
82 views

Is there a way to list Arch Linux packages by original install date?

I'm looking for a way to list my installed packages on Arch Linux in order of their original install date (not the date the current version of the package was installed; the date of the very first ...
0
votes
1answer
88 views

How to accept a list of files on the command line and use xargs to create a dated copy of all of them (basename_date.extension)?

I've been spending quite a lot of time working this problem from here out and I've managed to get the correct output without leaning on xargs calling bash (which the tutorial hasn't covered). It took ...
11
votes
2answers
670 views

Is there a way to use the day of year as an input format for the date command?

Using the command $ date +%j gives an output of the day of the year (001-366). However I need to use the day of the current year as an input format i.e. $ date --date='066 day' +%F Which for year ...
0
votes
2answers
85 views

BusyBox date: retrieve date from the internet without ntpdate

Embedded poky linux, no ntpdate available. It looks like none of the following commands is suitable: # date -s "$(curl -s --head http://google.com | grep '^Date:' | cut -d' ' -f 3-)" date: ...
0
votes
1answer
7 views

Does change of date or inconsistency between date and hwclock affect to ipv4 (inet addr) in ifconfig in linux?

I have trouble that inet addr(ipv4) of eth0 disappears and eth0 interface becomes unavailable. I'v not waited for refresh but I thought it would not restore itself. I guess that It Occurs When I ...
0
votes
2answers
18 views

coreutils date does not return time zone when called from script

In terminal, the output of the lines TZ="Australia/Broken_Hill" date -d '2021-4-26 09:29' TZ="Australia/Broken_Hill" date -d '2021-4-26 09:29' +%Z is Mon Apr 26 09:29:00 AM ACST ...
0
votes
4answers
164 views

How do I create a bash script that create a folder for every week of the year?

I want to create a folder for every week of the year with the name of the folder name being the Monday date of that week. For example from this week for the next weeks it would be: 02-22 03-01 03-08 ...
0
votes
0answers
22 views

How to identify the list of patches installed on Solaris 10 and 11 with date?

How to identify the list of patches installed on Solaris 10 and 11 with date? Showrev -p and patchadd -p does not have date on Solaris 10. Pkg list is not giving date for Solaris 11.
0
votes
5answers
72 views

Get the date, month, year from filename and convert it to a date format

I have a file with the name data_extraction_check_03_02_2021.txt. I am trying to get the last three values from the filename which is in the order of date, month and year. After that, I need to ...
-1
votes
1answer
43 views

How to change all files in directory creation/modification date to 0/0/0?

I want to change all files in directory creation/modification date to 0/0/0. I tried to use find $PWD -exec touch -m -d '0/0/0' {} + command.
-1
votes
1answer
58 views

change last modification date for many files using references

I have performed a backup and on restoring it, unfortunately, all file access times were set to the timestamp of the DateTime of this restoring process. How now to set all timestamps from the backup (...
0
votes
2answers
57 views

Need to validate the Input Date is in correct format(mmddyyyy)

I am trying to validate the date entered by the user(mmddyyyy),used the below but its not working, please correct me where i am wrong. date "+%m%d%Y" -d "02012019" > /dev/null ...
1
vote
1answer
91 views

What is %z useful for in GNU date?

I'm in the UK running these 2 commands (using gdate as I'm on a Mac with date (GNU coreutils) 8.32 installed): # A UK winter date, timezone in UK at this time is GMT = UTC $ gdate '--date=TZ="...
1
vote
2answers
40 views

Add timezone offset to a localized timezone

I am trying to obtain a date string corresponding to "yesterday" (to be understood as 1 day ago) in both a Ubuntu 20.04 and a CentOS 7. I have been successful up to now by using a non-...
0
votes
0answers
13 views

Issue in calculating elapsed time in millisecond date command not found [duplicate]

I have the following code trying to calculate how much time it takes in milliseconds to build a docker container. However I am facing syntax error and command not found issue, running bash script bash ...
-1
votes
2answers
85 views

Print all entries in file after (and including) a specific time

This is my date format in my file: [1/24/21 9:19:20:183 MYT]. I want to print all entries marked with timestamps from this moment onward to the end of the file. How can I do this using sed?
0
votes
1answer
22 views

GNU date command jumbling day and year when giving the proper format specifier

I have come across this weird behaviour of GNU date. date -d "29-May-20 09:29 1 minute" +"%d-%b-%y %H:%M" gives output: 29-May-20 09:30 --> Note: I have given here the ...
0
votes
1answer
26 views

date command calculating one month before from given variable

if there is no argument i can generate the current month and year(012021) and lastmonth(122020) with "-d 'last month'" option. if I entered argument like "01/01/2019" i can handle $...
0
votes
2answers
117 views

Convert date to second or day number

I need to convert a date into a day number and I can use date +%s --date "10 March 1990" 637027200 To get the second number. Then I divide that number to the number of seconds in a day - ...
1
vote
2answers
46 views

Using test and date to compare current hour ro range

I am new to Gnu/Linux and bash, and I am trying, unsuccessfully, to write a simple bash script to test if date +%H is within a predefined range of hours. Example: hour='date +%H' if [[ $hour -ge 12 ]] ...
0
votes
0answers
104 views

Viewing images date-wise in an image viewer

I am on Debian testing. I have come across this problem before and haven't found any resolution so far using search-engines, perhaps not precise enough, dunno. The thing is I have a folder/directory ...
1
vote
3answers
68 views

Changing a filename format from ‘2020-12-09’ to ‘2020.12.09’

I’ve figured out how to add a date to the beginning of my files using Bash. The issue is I use the format 2020.12.09 - filename for all my files historically and prefer it. The command I have adds the ...
1
vote
0answers
77 views

systemd dbus service continuously updates system time

I am trying to set my centos vm's date to 1 months prior date for some license validation, for that I have disabled systemd-timesyncd and ntpd service but still after setting the time to -32 days the ...
1
vote
1answer
36 views

Search files by specific time e.g. changed in the last 14 days

I am using Nextcloud and since the "retention" app is still not working on v20 I try to code an autodelete script for myself. The problem is, when I upload files to the Nextcloud share the ...

1
2 3 4 5
21