
extract text from log file
I use gawk and assume:
- you have always 5 columns separated by whitespace;
- the last field is always separated by three "_"
- the time ist always in HHMM format
Then you could write the following script "extract_time.awk":
{ split($5, split_array, "_")
raw_time = split_array[4]
formatted_time = substr(raw_time, 1, 2) ":" substr(raw_time, 3, 2)
print $0 " " formatted_time
The next question is: where do you want the formatted output. The
script appends the formatted time at the end of each line. Change
the line with "print" according to your needs.
Then call the script with:
gawk -f extract_time.awk logfile > outfile
--
hans juergen mueller