Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

All Questions

Tagged with
1
vote
1answer
28 views

collect logs from bash each 24 hours [closed]

my idea is to collect logs each 24 hours ,mail it and flush them after that i wrote some scatch for example 1.var/log/auth {some info} 2.var/log/something.log {some info} list="$(find /var/log -...
0
votes
2answers
52 views

How to obtain the last recently three dates of a file log?

How can I print the last three dates of the next output: User;month/day/year user1:01/01/2015 user1:01/01/2015 user1:01/01/2015 ... user1:01/09/2018 user1:01/08/2018 ...
0
votes
1answer
87 views

Sed range problem if the last pattern is not met

I am doing a range search with sed. I want to parse the log data from the date and time 2016-09-29 01:00 to 2016-09-29 01:30. That is why I have been using the following command, $ sed -n '/2016-09-...
1
vote
2answers
525 views

Script to convert epoch time to human readable format

I have a file which contain multiple rows. Some rows represent date and time but that time is in Epoch format. I have tried using some command but that command converted all of the numeric digits. I ...
0
votes
2answers
25 views

Get lines formatted with a specific date or later

I am looking at logs files that have timestamps and I just want the entries from a specific time period and after. 2018-06-17T13:43:09 For example I want all entries from 18:00:00 on 2018-06-23 and ...
1
vote
1answer
284 views

Delete lines in web server log file older than X days?

I'm running Nginx on Ubuntu with the default 'main' log format, which produces output like this: 95.108.181.102 - - [11/Feb/2018:11:43:10 +0000] "GET /blog/ HTTP/1.1" 200 4438 "-" "Mozilla/5.0 (...
0
votes
5answers
687 views

using sed command to replace first 2 occurrences of “:” within a string

I am trying to compare 2 dates in the format YYYY:MM:DD HH:MM:SS by using the date (bash) command. My problem is that the date command only uses the date format (as far as I know) YYYY-MM-DD HH:MM:SS. ...
0
votes
3answers
3k views

Calculate Time difference between two lines

grep timestamp in a file as given below. Now I need to calculate time difference file data: 18:29:10 04:56:50 I tried following command its output is in minus: awk -F":" 'FNR==1{split($0,a,":");...
3
votes
3answers
371 views

One Liner sed date string to unixtime

I'm running the following command: cat /tmp/myfile.log | sed -n -e 's/^.*Expire: //p' Which returns the following string 04-nov-2018 I then want to run that string through the following command: ...
1
vote
0answers
462 views

Getting a range of lines between timestamps from /var/log/messages

I want to get all lines between two timestamps from /var/log/messages. I only have start time which I provide to my script as input. The script then should get me all the lines till next day as output....
0
votes
2answers
213 views

'sed' date formatting issue

I am getting a file from database using shell script. Data looks like below after running shell script.This is a pipe separated data file. 4676004||2017-09-2900:00:00|13222|0|XYZ|TTTTT||...
1
vote
1answer
131 views

print the date of a mail.log line

I have a mail.log line and using sed and pipes I can extract the subject, the sender, and the recipient of the mail, echo "Jul 15 09:04:38 mail postfix/cleanup[36034]: 4A4E5600A5DE0: info: header ...
1
vote
6answers
3k views

How to extract the year from date (mm/dd/yyyy)

How can I extract the year from a date in the form mm/dd/yyyy? I have a text file that has the following dates: 01/01/2001 05/16/1970 06/08/2010 How can I use sed to extract only the year from each ...
1
vote
2answers
669 views

awk, cut characters out of substring

I have the following csv. I'm trying to remove the 20 out of 2017 so it's formatted like 3717 or 31817. The positions are always different due to some dates having single digit days. Since the year is ...
0
votes
3answers
62 views

display all patches/packages installed in the last month

I would like display all the installed packages of last month with the rpm -qa --last command which outputs in this format: libgcc-4.4.7-17.el6.x86_64 Tue 01 Nov 2016 12:55:21 PM ...
6
votes
3answers
3k views

Modify date format in-place through `sed` command

I'm trying to modify the dates in a text in place where there are as 2016-Dec-24 or 2016-12-24 and I have to replace them like 24/12/2016. Is there any way I can use sed -i to do this? Input ...
9
votes
6answers
9k views

How to replace epoch timestamps in a file with other formats?

I have a file that contains epoch dates which I need converting to human-readable. I already know how to do the date conversion, eg: [server01 ~]$ date -d@1472200700 Fri 26 Aug 09:38:20 BST 2016 .....
2
votes
3answers
2k views

Log file grep entries from last 30 min

I am creating a script that will email errors/warnings from a log. I would like to have this sent every half hour but I only want to send it if there is a new entry. How would I grep out only the last ...
2
votes
3answers
643 views

Truncating the precision of a date

I'm working with a bash script which polls build progress from several different systems. If a build is complete, it stats a log file to find out the last time it was edited, then feeds that time into ...
2
votes
3answers
808 views

Reformat date string

I am trying to figure out how to reformat a file full of wrongly formatted dates. The source looks like this: {"_id":"","timestamp":"Mon Apr 20 08:30:55 +0000 2015"} {"_id":"","timestamp":"Mon Apr 20 ...
1
vote
2answers
265 views

How to mark dates which are in the past?

From the answers I updated the question: Now, it's: $ date "+%F %H:%M" 2014-06-04 11:26 This is the input: $ cat input.txt <tr><td>2014-04-24 14:01</td><td>2014-06-04 ...
3
votes
2answers
614 views

Highlight today in Mac's cal

Every Mac comes with cal which shows a simple calendar of current month. Output is something like this: February 2014 Su Mo Tu We Th Fr Sa 1 2 3 4 5 6 7 8 9 10 11 12 13 ...
2
votes
3answers
707 views

get list of months using dseq from dateutils

how'd I get a listing of the months in the year (abbreviated) using dseq from dateutils? NOTE simply running: dseq 'jan' 'dec' -i '%b' -f '%b' returns a humongous list of months: piping the output ...
40
votes
2answers
27k views

Removing leading zeros from date output

I made an alias of the date command to display date in the following format: 2013.06.14.12.10.02 using this command: alias date = date +"%Y.%m.%d.%H.%M.%S" Everything works great, except I want ...
0
votes
4answers
102 views

How to make 1:52 to 01:52 with eg.: sed?

INPUT: a|2013.06.13. 13:22|xx b|2013.06.13. 1:52 |xx c|2013.06.13. 2:26 |xx OUTPUT: a|2013.06.13. 13:22|xx b|2013.06.13. 01:52 |xx c|2013.06.13. 02:26 |xx How can I make the 1:52 to 01:52 in this ...
4
votes
1answer
92 views

How to edit files in-place while performing operation on the values matching the searched pattern?

Given a list files containing random text and many datetimes in ISO format in it (e.g "2012-07-02T10:47:24+02:00"), how can I find all these datetimes and add 2 hours to each one ? Ideally a solution ...
1
vote
2answers
2k views

Parsing the output of date with sed

I am trying to replace the whitespaces in the output of date with '_' with no success. $date Fri Sep 14 14:10:04 EDT 2012 $ date | sed 's/ /_/' Fri_Sep 14 14:10:24 EDT 2012 As you can see, the last ...
0
votes
2answers
641 views

Shell output question

What is the output of date -u +%W$(uname)|sha256sum|sed 's/\W//g' (on Arch Linux if it matters)? How do I find that out?