using awk on a file
Hi
I have the following jboss_gc.log and i want to convert to csv file . Any ideas why the awk below is not paring the file correctly ? gc.log file Code:
3.811: [GC 129152K->9220K(261184K), 0.0536640 secs] Code:
|
None of the lines you posted has 8 fields, so the first
Code:
awk '{print $8}' |
This is the file
Code:
64519.455: [Full GC 784436K->538165K(784448K), 12.7143926 secs] |
avoid writing such chains: grep | awk | awk | awk | awk
You need only one awk to implement this: Code:
awk ' BEGIN { FS="[- ,K>()]*" } /Full GC/ { print $6 "," $7 } ' >> /tmp/out.csv __________________________________ Happy with solution ... mark as SOLVED If someone helps you, or you approve of what's posted, click the "Add to Reputation" button, on the left of the post. |
This still gives me nothing back
Any ideas why ? Code:
|
Code:
awk ' BEGIN { FS="[- ,K>()]*" } /Full GC/ { print $6 "," $7 } ' $GC_LOG >> /tmp/out.csv |
Thanks that worked now if i also want to check if there was more than one Full GC string in the file i will throw an error
How could i handle that ? |
Code:
awk ' BEGIN { FS="[- ,K>()]*"; counter=0 } /Full GC/ { if ( counter++ ) { exit 1 } else print $6 "," $7 } ' $GC_LOG >> /tmp/out.csv { print "THIS IS AN ERROR" > "/dev/stderr"; exit 1 } _____________________________________ If someone helps you, or you approve of what's posted, click the "Add to Reputation" button, on the left of the post. Happy with solution ... mark as SOLVED (located in the "thread tools") |
All times are GMT -5. The time now is 12:23 PM. |