Updated November 22, 2004
Created November 22, 2004


Autogenerated Site Map
Search this Site!:
Search this site powered by FreeFind
Working with multiple lines

A method to join 2 lines, I had found that splitting was easy, but selectively joining was difficult. Here's my results:

Original input:

/dev/hde:
Timing buffered disk reads: 168 MB in 3.01 seconds = 55.73 MB/sec

/dev/hdi:
Timing buffered disk reads: 168 MB in 3.00 seconds = 55.97 MB/sec

/dev/hdk:
Timing buffered disk reads: 170 MB in 3.05 seconds = 55.78 MB/sec

For me to intelligently grep for good/bad speeds, I need the 2 lines put together. Also this input is kludged up with CRLF (DOS) line terminators:

Solution:

All you need is the inner loop portion, I need the outer loop because I have a bunch of files I'm cycling through in order to get my results. That is an "or" on the grep where I accept lines with "dev" or "Timing".

find . | sort | grep 10.90.1.184 | grep hdparmquery.log | while read FILENAME; do cat "$FILENAME" | grep "dev\|Timing" | dos2unix | while read; do echo $REPLY | grep "/dev/" >/dev/null && { echo -ne "$FILENAME $REPLY "; } || echo "$REPLY"; done; done > /tmp/hdparm-results-for-10.90.1.184.txt

Results:

./20041008121054/10.90.1.184.20041008121108.hdparmquery.log /dev/hde: Timing buffered disk reads: 170 MB in 3.04 seconds = 55.84 MB/sec
./20041008121054/10.90.1.184.20041008121108.hdparmquery.log /dev/hde: Timing buffered disk reads: 170 MB in 3.03 seconds = 56.10 MB/sec

Search this Site!:
Search this site powered by FreeFind

Homepage: http://www.cpqlinux.com
Site Map: http://www.cpqlinux.com/sitemap.html