New answers tagged date
0
votes
Set explicit time with date
Like this:
date '+%F %T' -d "2022-04-10 12:12:12"
2022-04-10 12:12:12
Check:
man 3 strftime
- 29.2k
1
vote
Accepted
Output date into specific column using bash
i have a little awful script that does something similar to what you want:
awk -i inplace -v myvar="$(date)" 'BEGIN {FS=OFS="," ; flag = 0}; \
{if (!flag && $2=="&...
- 36
0
votes
Output date into specific column using bash
I found a lot of ways to output specific text or variables into a csv file but not a command.
The store the date output into a variable, and proceed on your way:
$ TheDate=`date`
$ echo $TheDate
Mon ...
- 914
1
vote
Accepted
Unix: how to get number of days from a given date like 10Dec2022
If it's about getting the number of days since that date, with ddiff from dateutils (sometimes called dateutils.ddiff):
$ date +%F
2023-03-22
$ dateutils.ddiff -i %d%b%Y 10Dec2022 now
102
That's ...
- 505k
2
votes
Unix: how to get number of days from a given date like 10Dec2022
If you need to fetch the number of days since the start of the year for given date:
With GNU date:
$ date -d '10Dec2022' +%j
With perl:
$ perl -MTime::Piece -sE '
say Time::Piece->strptime($...
- 29.2k
3
votes
Accepted
Where is timedatectl information stored?
The last known “good” timestamp is stored as the modification time of /var/lib/systemd/timesync/clock. The minimum value used is the systemd build date. It is updated whenever time is synchronised ...
- 394k
0
votes
How do I convert an epoch timestamp to a human readable format on the cli?
If UTC is your preference (for the sample epoch timestamp 1666666666),
$ # long options; Linux
$ date --date=@1666666666 --utc
Tue 14 Nov 22:13:20 UTC 2023
$ # short options; Linux
$ date -d @...
- 203
1
vote
Compare multiple date & time in shell script
Assuming that you have some JSON document like this:
[
{ "datestring": "Mon Feb 20 09:22:25 2023" },
{ "datestring": "Mon Feb 20 17:42:13 2023" },
{ &...
- 312k
0
votes
Compare multiple date & time in shell script
With GNU sort or compatible, you can sort that input chronologically using:
LC_ALL=C sort -b -k5,5rn -k2,2rM -k3,3rn -k4,4r
Here in reverse from latest to oldest so you can pipe to head -n1 to get ...
- 505k
0
votes
Compare multiple date & time in shell script
you can use date command to convert those dates to unix timestamps and just sort them, and you can then convert them back to any format you want.
Example, converting date to timestamp and then back:
...
- 1,936
Top 50 recent answers are included
Related Tags
date × 1147bash × 202
linux × 199
shell-script × 195
shell × 110
time × 87
files × 86
awk × 80
timestamps × 73
timezone × 72
text-processing × 67
command-line × 57
find × 50
scripting × 44
sed × 40
logs × 35
sort × 32
grep × 30
cron × 30
debian × 26
macos × 25
locale × 24
rename × 22
solaris × 20
filenames × 20