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
0
votes
4answers
99 views

Is there a way to get the date range from a csv file?

I want to find the date range for each of the 4 CSV Files in a directory. The date column is the last column in each csv and is of the form 1/25/2012 7:20:55 PM. The date field is always the last ...
3
votes
3answers
36 views

Sorting by date with format dd-Mmm-yyyy from specific file

So I am having the following file: Certificate Name,Expiry Date,Type,Certificate file path CN=server10.de.go.com:app, 16-Jan-2021, physical, /path/to/file/ CN=sv999-c.int.de.aaas.internet....
27
votes
1answer
2k views

Why is `TZ=Asia/Kolkata date --date=“1/1/1906”` invalid?

When I run: TZ=Asia/Kolkata date --date="1/1/1906" I get: date: invalid date ‘1/1/1906’ Here I can find a good article on that: Calcutta Time But the confusion also comes from the fact ...
2
votes
3answers
37 views

Construct daily 6 hourly date series (4 time-steps a day) using linux “date” command

I am trying to construct a daily 6-hourly date series for some 'N' number of years. I tried to do like this for i in {1..1825}; do date -d "00:00 01-01-1998 +6 hours" +"%d-%m-%Y %H:%M&...
0
votes
1answer
30 views

convert directory names with german 'now' date to YYYY-MM-DD

I exported pictures from mac's iPhoto. The directories are named with the date in local naming ("Day. MONTH YYYY"): 8. Mai 2013/ 13. Juli 2013/ 31. Oktober 2014/ and some of them with GPS ...
0
votes
1answer
19 views

Locale on polybar is in US format instead of BR

Context: I'm running ArcoLinux with i3 as my window manager and polybar as my bar. During installation I chose the language to be English, America en_us. And Locale I chose Brazil, São Paulo. If I run ...
1
vote
2answers
42 views

Modify date to -7 days in .csv file via shell script

I have a file with records in this format : D20200826,S2927,977,1 Expected output : D20200819,S2927,977,1 Now what I am trying to achieve is if somehow I can get the date (first column) to be moved ...
2
votes
3answers
57 views

How to add X amount of year to YYYYMMDDHHMMSS format in bash?

Bear with me I am not strong with bash. I have a date/time as in YYYYMMDDHHMMSS format such as 20031005000000in string. I like to add one year to it. I've read man date but it was a bit hard to ...
0
votes
2answers
69 views

Log search within date range

My log file looks like the following sample: 10.434.22.334 - unauthenticated 10/Aug/2020:23:45:45 +0800 "GET /eai/random.jsp HTTP/1.1" 200 74 10.434.22.334 - unauthenticated 10/Aug/2020:23:...
1
vote
1answer
34 views

Bash scripting test that a datetime is in the past?

I'm writing a bash shell script one of whose arguments is a datetime. What's the best way to check if that date is in the past (or a certain amount of time in the past (e.g. “this was at least 3 days ...
1
vote
2answers
71 views

GNU Date: inconsistency calculating number of days between dates

I am trying to calculate the number of days between two dates like this: $ echo $((($(date +%s -d 2016/11/22)-$(date +%s -d 2016/11/20))/(3600*24))) days 2 days That is the expected answer and ...
3
votes
2answers
188 views

Sort an output by year month and date

I want to sort the output below by year, month and date. I tried a few combinations that don't seem to be working. In the below output 2nd column is the date, 3rd is the month and 4th is the year. I ...
0
votes
1answer
24 views

how to match log file with date syntax

we have logs like this more log 20/08/02 13:41:39 some text at org.apache.hadoop.hdfs.protocolPB.ClientNamenodeProtocolServerSideTranslatorPB 20/08/02 13:41:40 some text 20/08/02 13:41:41 some text ...
0
votes
1answer
20 views

How to get +HHMM offset of TZ=“Asia/Tokyo” compared to current time-zone using bash?

I am taking input for TZ and I want to convert it into a (+/-)HHMM format. but not compared with UTC, I want it to be compared with the local time. How can I do it?
0
votes
3answers
52 views

How to get particular date

There is a need to get first Saturday date of current month in my script. I am able to get last Saturday date from below command date -d 'last Saturday' +%y%m%d But unable to get First Saturday date. ...
2
votes
3answers
157 views

How do I set a value when running find command?

I'm running a long string of -exec commands, and I want to pull a timestamp from the beginning of the run to use as a value for subsequent commands. Is this possible? Something like: find . -exec NOW=$...
0
votes
1answer
45 views

Taking an integer and creating a date format

I can take a date and convert is to an integer. date_as_integer = $("2020-06-13" | sed "s/-//g") However is there a way to convert it back to date?
1
vote
2answers
23 views

GNU date: truncate provided date-time and set provided hours

I have a timestamp value in a variable and I need to truncate the hours from it and set different hours. Can GNU date do this in one go? It definitely does this for special dates like "today"...
2
votes
1answer
55 views

Print datetime each time I hit the return key

I am searching for a way of prefixing the date command every time I run a command on the terminal (I am currently using zsh). The reason for this is that I usually run scripts that take a long time to ...
0
votes
0answers
23 views

istat command in a script

I have a file that must not be modified. I used the stat -c %Z command in Linux but now I use AIX. I want to have only number after using istat file, like this: day+h+minit+second+ years For example: ...
-1
votes
2answers
60 views

How to delete deployments of a greater than date from awk list [closed]

I need to delete deployments that are older than 14 days on clusters. if I run: oc get deploy --sort-by=.metadata.creationTimestamp | grep wml-os-rt-hybrid | awk '{ print $1 "\t\t" $6;}' ...
0
votes
0answers
13 views

Debian: setting the specific priority for sudo command by user account

I want to ask how to set the priority of sudo command with user account: I create a new account named user A. And now I want to modify the ntp date and time read temperature of CPU.   But it needs ...
2
votes
1answer
31 views

Long listing showing hours since modification

Is there an option (preferably a GNU and/or FreeBSD option) that instructs ls to display modification time, not in absolute date time, but instead showing a number indicating hours (or days) since ...
1
vote
2answers
67 views

Fetch the series of logs in between date range when the range contains specific string(s)

I am searching for multiple range of lines from a file with in a given date range when the search string(s) exists. I am not an Unix expert, don't know how to achieve this. After googling I was able ...
0
votes
1answer
31 views

Comparing dates of different formats and matching it from another file

I have two data files with date stamps in different formats (as text in the file contents).  I wish to compare the two dates and print the variable from one file to another according to date in a ...
0
votes
1answer
30 views

find a file based on date passed in parameter

I have a requirement to find a next day file based on date provided in the parameter. For example, I have these files: XYZ.ABC.M.20200615180200.batch XYZ.ABC.M.20200616180200.batch XYZ.ABC.M....
0
votes
0answers
27 views

Purge lines in a file based on age in shell script

I wanted to record the slave delay in mysql server every minute,so prepared a simple script. #!/bin/bash echo "`date` : `mysql -uroot -pXXXXXX -e"show slave status\G" | grep -i ...
0
votes
1answer
30 views

Archive files not modified for more than 6 months

I have a python method to archive files not modified in 6 months to another drive by iterating through the directories. But what is the fastest way to find all non-modified files from the whole ...
0
votes
3answers
41 views

I am working in Sun OS, I want my script to read date from a file(in format %Y%m%d) and add 1 day to that date

I am working in Sun OS environment, I want to add a functionality to my existing unix ksh script where it allows to read a date(in %Y%m%d format) from a file and add 1 day and rewrite the same into ...
0
votes
1answer
44 views

Is there a way to substring or cut a part of value of a unix variable without using echo?

Is there a way to substring or cut a part of value of a unix variable without using echo? For example i have a variable containing a date. pDate=2020-06-22 I need to pass the year and month into ...
-1
votes
1answer
32 views

How to search in Ubuntu/Linux using two different date?

Please assist. I am trying to search few events in Ubuntu from auth.log and syslog in /var/log/ folder using two different date range, how can I do it? My Code is like below with only one date range ...
1
vote
0answers
44 views

Call script in locale definition

I am following the answer in https://askubuntu.com/a/162714/146591 to generate a custom locale on my system. Many of the fields that can be configured in a locale are input for the date utility (https:...
0
votes
1answer
23 views

Using a bash script to write current date to a .cfg/text file

I'm trying to get the current date as month/day (i.e., 6/18), printed into a .cfg file (using sed because I need a specific line changed). However, when running the bash, the date is correct in the ...
1
vote
1answer
61 views

How date command keep tracking time

I got a weird scenario in which the date of my computer is getting the wrong time (and he keeps fixing the time but still keep repeating this issue) let me share with you an example who make this much ...
0
votes
1answer
47 views

busybox format date

I got a command which works perfectly on linux date -d @$(git log -1 --format=%at) '+%Y-%m-%d_%H-%M-%S' and now i'm trying to do same formatting with busybox, but i always fail
-2
votes
2answers
58 views

convert milliseconds column to seconds in a csv file [closed]

I have a large tab separated file without headers like this: Tue Jun 09 18:06:53 GMT 2020 1591726013187 Tue Jun 09 18:20:31 GMT 2020 1591726831779 Tue Jun 09 18:09:01 GMT 2020 1591726141456 ...
0
votes
1answer
28 views

Expanding Date Command inside single quotes in linux

I am new to linux. I am wondering why date command is not expanding inside single quotes. so if i give command like below d=$(date +%m%d) echo 'A1D$d' Output is A1D$d But If i give without quotes ...
0
votes
1answer
19 views

How to list and put log's name to a file according to date

I have bunch of log files. And some of them are rotated. Say I want to put their name in a txt file. -rw-r----- 1 admin staff 5120126 Apr 20 14:29 access.log00071 -rw-r----- 1 admin ...
1
vote
0answers
54 views

Sheduling a shell script using crontabs for a rolling 5 hour interval across days [duplicate]

I need to schedule a shell script execution with crontabs to execute it every 5 hours starting from 01:00 and daily. sample execution times: 2020-05-29 01:00 2020-05-29 06:00 2020-05-29 11:00 ...
0
votes
0answers
74 views

Value too great for base

I'm trying to display how long it takes for my script to execute in both seconds and milliseconds. This is my code: #!/bin/bash before=10#`date +'%s%N'` sleep 1 after=10#`date +'%s%N'` echo "$...
0
votes
3answers
60 views

Time elapsed of a bash script (days/minutes/seconds)

Infact when i want to have an estimated time it took when a script is finished. startdate=$date stuffs enddate=$date I wished to get the difference between these two dates and normally the script ...
1
vote
2answers
132 views

Is it planned to incorporate the Olson database for TZ in POSIX for `date`?

There is a simpler way to define the value of the timezone, the Olson database. It has been supported for 19 years (Paul Eggert) by Solaris, HP-UX and Tru64. It is certainly supported by AIX as the ...
0
votes
0answers
26 views

Date format in freebcp's locales.conf

The freebcp command fails to bulk upload my csv to MSSQL. After much debugging, it seems this is due to the date format. The second column of this csv is '2020-05-13', but it turns it into %b %e %Y %...
3
votes
2answers
111 views

Invalid date when converting timestamp with awk

I'm trying to find a way to convert timestamps in log files to a Unix timestamp. The command I have come up with so far is the following: awk -F'[' '{ print $2}' | awk -F']' '{cmd ="date \"+%s\" -d \"...
0
votes
2answers
46 views

“date” command doesn't show many timezones on Centos 8

On a fresh Centos 8 system, the date command does not show many timezones even though the timezone is properly set by timedatectl and /etc/localtime points to the correct TZ data file. For example: #...
0
votes
2answers
31 views

Sort a column with two different datetime format

I have a tab separated file and the date columns contains date with two different formats. I am using this sort command to sort by one format type ("%a %b %d %H:%M:%S %Z %Y"), but is there any way to ...
0
votes
3answers
41 views

Displaying time and date next to part of the ping output

#!/bin/bash ping -c 1 8.8.8.8 | awk '{print $7}' date So for the code above, I want it to display the date and time in this format below Tue May 5 11:11:11 UTC 2020 time=0.838 ms So far it prints ...
0
votes
3answers
49 views

Get the epoch time and add it as a new column

I have the following tab separated input file, with timestamps in UTC. How can I calculate the epoch time an add it as a new column? It is a large file with over 60MM rows. a b 0 2020-03-03 15:46:...
0
votes
1answer
28 views

Adjusting the 'date' command to subtract three hours

In a bash script, I have the following 3 lines: D=`date -u +%Y%m%d` H=`date -u +%H` RUNTIME="${D}_${H}00" I need to have the RUNTIME adjusted to 3 hours earlier than the current time. So this would ...
1
vote
2answers
70 views

Find the age of the oldest file in one line

I tried stat -c %Y ./* 2>/dev/null | awk -v d="$(date +%s)" 'BEGIN {m=d} $0 < m {m = $0} END {print d - m}' to find the age of the oldest file in the current directory, and I get a number in ...

1
2 3 4 5
20