All Questions
67 questions
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'...
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....
-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 |...
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 ...
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 ...
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: ...
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-...
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.
...
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 ...
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 ...
2
votes
2
answers
350
views
Find pattern: sort and delete older files
I want to delete old files and keep only the most recent from each file pattern based on the first five characters (aa_te, bb_co, cc_co, dd_xy) and the date and time in the file name.
Note:
All files ...
2
votes
2
answers
2k
views
how to increment date from a to b?
I have 2 dates, start=20190903 & end=20210912
and want to increment till start approaches the end, increment is 13 days.
have following code, but it exceeds end.
#! /usr/bin/env bash
start="...
2
votes
1
answer
551
views
Generate timestamp between 2 values
Im trying to generate a timestamp series between 2 timestamp values with 30mins interval.
Here is what I already prepared.
start_ts='2021-08-07 15:00:00'
end_ts='2021-08-11 05:00:00'
while ! [[ $...
3
votes
2
answers
1k
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
1
answer
1k
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 ...