Friday, April 1, 2016
Linux Bash Shell Script Time Interval Regex with Piped Loop to Print Log Data
April 01, 2016
beginner
,
code
,
easy
,
explanation
,
expression evaluation
,
grep while
,
linux
,
pipelining
,
piping
,
read line by line in variable
,
regex
,
regular expression
,
script
,
shell
,
time interval matching
,
time regex
,
tutorial
How the code below works:
The code below by getting all the lines within the log.txt with matching times. Next it reads the data line by line in three separate variables and prints the data.Input File:
Save the input in file named "log.txt".Code To Match Time Interval:
Save the code in a file named "TimeIntervalRegex.sh".Running the Code:
Just type the code below in terminal. Make sure to cd into that directory if you have not opened the terminal in that directory.bash TimeIntervalRegex.sh
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment