sed 2 hours in log


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting sed 2 hours in log
# 22  
Old 02-18-2013
Here I want to use any of the following single characters as field seperators: /, [, ] or space.

This equates to the regular expression [/ \][] (just like [ABC] would allow a single A, B or C character)

Because the \ (backslash) character means something to the shell we need to escape it (using another backslash) to ensure our required regular expression gets passed through to awk intact.

You can see in this demo code how awk gets as it's final FS value:

Code:
$ echo "[10/12/2012 10:51]" | awk -F"[/ \\\][]" '{ print FS ; print $2; print $3; print $5 }'
[/ \][]
10
12
10:51


Last edited by Chubler_XL; 02-18-2013 at 05:08 PM..
This User Gave Thanks to Chubler_XL For This Post:
# 23  
Old 02-19-2013
Thanks, gracias, danke, merci Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Parsing log file for last 2 hours

I want to parse a log file which i am grepping root user connection but is showing whole day and previous day detail as well. First i want to see last 2 hours log file then after that i want to search particular string. Lets suppose right now its 5:00PM, So i want to see the log of 3:00PM to... (6 Replies)
Discussion started by: learnbash
6 Replies

2. Shell Programming and Scripting

Log search and mail it if the log is updated before 24 hours from the current time

Hi , We have around 22 logs , each has different entries. I have to automate this using shell script. The ideas which am sharing is given below 1) We use only TAIL -100 <location and name of the log> Command to check the logs. 2) We want to check whether the log was updated before 24... (13 Replies)
Discussion started by: Kalaihari
13 Replies

3. Shell Programming and Scripting

Need help looking for missing hours.

I have a file that should cover a days worth of stats, at the beginning of each 15 minute report I have a unique header that looks like the below example. The "0000" and "0015" will change in the header line to show which 15 Minute interval the report is covering and of course from day to day the... (7 Replies)
Discussion started by: fsanchez
7 Replies

4. Shell Programming and Scripting

ps -ef |grep 24 hours

I need to grep PIDs older than 24 hours (1 day) or more. ps -ef |grep ??? Please advise. (10 Replies)
Discussion started by: Daniel Gate
10 Replies

5. AIX

cron off by 5 hours

stupid question im sure, but its frustrating My cron jobs are off by 5 hours. My system time is right but all of my cron jobs are running approximately 5 hours late. Any idea why? (4 Replies)
Discussion started by: mshilling
4 Replies

6. Shell Programming and Scripting

CurrentTime-4 hours

Hi, Good Afternoon! I am writing this script on "sh" and have Variables as below. #Time in hours ex: 09 JobTime=`echo $StartTime |awk '{print $2}'|cut -f1 -d':'` SystemHours=`date +%H` How can go 4 hours back for each variable in a day? Another Question? JobStat=`dsjob -report... (5 Replies)
Discussion started by: rajubollas
5 Replies

7. What is on Your Mind?

How Many hours on Computer?

How many hours you spend on Computer in a day??? (10 Replies)
Discussion started by: malcomex999
10 Replies

8. Shell Programming and Scripting

how to list files between last 6 hours to 3 hours

Hi Frens, I want to list some files from a directory, which contains "DONE" in their name, i am receiving files every minute. In this i want to list all the files which are newer than 6 hours but older than 3 hours, of current time i dont want my list to contain the latest files which are ... (4 Replies)
Discussion started by: Prat007
4 Replies

9. Shell Programming and Scripting

Last 24 hours of a log file

I'm looking to pull the last 24 hours of a log file. Here's what I've got so far: yesterday=$(TZ=$TZ+24 date +"%b %e %H:%M") today=$(date +"%b %e %H:%M") echo $yesterday $today grep -E "^$yesterday|^$today" /var/adm/syslog/syslog.log But that pulls everything from $yesterday from... (1 Reply)
Discussion started by: Bert
1 Replies

10. Shell Programming and Scripting

move log files over 12 hours old...

Hi, I know I can use touch and find's "! -newer" option to list files that are older than a specific time, but what is a good way to get a list of files that are over 12 hours old? The log pruner will run throughout the day, twice an hour. So I can't easily use a cronjob touch command to generate... (1 Reply)
Discussion started by: Thomas Pluck
1 Replies
Login or Register to Ask a Question