Archive for July, 2011

Print every lines of a file where last field value is > N

July 23, 2011

Consider the following scenario where the last filed of each line is basically the time taken to server a request by the app server – in our case it is ( say time=400ms). Now I want to see those lines which takes more than 400ms to server the request – here is the trick

cat prod_debug.log | grep ‘PROFILER’ | awk ‘{ sub(/time=/,””);print}’ | awk ‘{sub(/ms/,””);print}’ | awk ‘$NF>400’

Merging two corresponding line with sed on a file

July 23, 2011

Merging two lines

sed ‘$!N;s/\n/ /’ file1 > file2

Deleting blank lines –

 sed ‘/^$/d’  file1 > file2

Deleting all lines starting with ‘–‘

 sed ‘/^\–/d’  file1 > file2