Skip to main content

All Questions

Tagged with
4 votes
1 answer
324 views

ISO 8601 intervals in date arithmetic with date command

I can make some date arithmetic with date command like $ date -u -d '3 days 2024-12-01T00:00:00Z' +%FT%H:%M:%SZ 2024-12-04T00:00:00Z $ The date command can parse quite a lot of date formats, ...
Roux's user avatar
  • 143
2 votes
2 answers
502 views

using gnu date to set a time and format and subtract

Can I give GNU date a date and format string for that date and tell it to also subtract some time from it? It seems I can do 2 of 3 in 1 command but not all I have this date format: 09/Sep/24 05:02 AM ...
Christian Bongiorno's user avatar
2 votes
6 answers
655 views

Convert EPOCH string in filename to readable format

My knowledge of Unix is not very good. I'm trying to write a shell script to rename a set of files in a directory, like 1709532255.mp4 to 20240304_070415.mp4, where 1709532255 is always an epoch time. ...
tom's user avatar
  • 23
2 votes
2 answers
118 views

What's the KISS-way of turning format '1000 days' into format 2 years, 9 months, 0 days' within bash & shell scripting?

What's the "Keep It Simple" way of turning a format such as '1000 days' into format '2 years, 9 months, 0 days' within shell scripting? I've thought of applying modulor or floor rounding. I'...
futurewave's user avatar
2 votes
2 answers
516 views

Update any date to the current date in a text file

I have a text file which contains several occurrences of dates. All the dates are written in the format Mon-DD-YYYY. I have to update all these dates in the current date keeping the format Mon-DD-YYYY....
user9952796's user avatar
-1 votes
2 answers
590 views

Output date into specific column using bash

I want to output the date into a csv column using a bash script ignoring the header. I have this but it only gives the day of the week abbreviated and not does not place it in a specific column: date |...
robetus's user avatar
  • 113
0 votes
3 answers
1k views

Compare multiple date & time in shell script

I have below output with jq command , where I want to compare all the date & time and tell which is the latest one Mon Feb 20 09:22:25 2023 Mon Feb 20 17:42:13 2023 Thu Mar 2 05:55:07 2023 Tue ...
Samurai's user avatar
  • 95
0 votes
1 answer
1k views

How to change the modification date (The Metadata) of multiple files?

I have a gallery folder with multiple images and videos, some of them has their modification date correct, and some of them has the month wrong. I want to make a script that will change all the files ...
user avatar
2 votes
2 answers
3k views

Script - Compare filename date with current date

I'm trying to compare a file with date in its name to the current datetime of the system: Filenames are with the following format: FileName.yyyymmdd.hhmm.file (e.g. File156tr.20220914.0958.txt) I have ...
joniop's user avatar
  • 61
1 vote
4 answers
917 views

Given a weekday name, week of a month, and a year, how to find the date

I can find the last Monday using date -d 'last-monday' +%F but given a weekday name, week of a month, and a year, how to find the date? e.g. given: Monday, Week 4, June, 2022 output: 2022-06-20 given: ...
surz's user avatar
  • 21
22 votes
3 answers
4k views

What's the POSIX-compliant way to get the epoch timestamp in a shell?

I just noticed, that POSIX date doesn't seem to have the %s or %N format items. So I can't use those. What's an alternative, yet POSIX-compliant way to get the epoch timestamp in my shell script?
finefoot's user avatar
  • 3,504
3 votes
2 answers
301 views

Setting time zone in a kindle bash file

I've recently jailbreaked my kindle to make it a clock that shows a certain image for each minute of the day. I used the instructions mentioned in this article https://www.instructables.com/Literary-...
Amr M. El-Dawoody's user avatar
0 votes
1 answer
91 views

Subset of File between two dates, when some dates are invalid

I have come across several similar questions, but the solutions seem to be failing me, and I believe it is because I have some junk data in my file that is breaking my attempt to filter by time stamp. ...
Vint's user avatar
  • 107
0 votes
1 answer
2k views

How to convert Linux date to another date format

I am getting date in one of file in the format "Fri Feb 25 16:07:17 UTC 2022" Which I want to convert it to "2022-02-25 16:07:17". However I am able to do it using Python but its ...
prashant thakre's user avatar
1 vote
2 answers
994 views

date string is not updating within while true; do loop

I have a simple bash script: #!/bin/bash enp="$(ip route | grep "192.168.1.1" | cut -d' ' -f 3)" while true; do vnstat -l -i "$enp" --style 4 --json | awk '{ print ...
Ryan Burch's user avatar

15 30 50 per page
1
2 3 4 5
14