Quote:
Originally Posted by pixellany
Code:
cat filename |sed -n '2p'|cut -d " " -nf 3
Assumes that words are delimited by exactly one space. If more than one space, add another sed to replace N spaces with one.
Not tested:
|
Please stop doing that!
Use the form:
"sed -n '2p' filename |"
instead of
"cat filename | sed '/ */ /g' |"
There is absolutely no reason to use cat before sed or awk unless you want to add line numbers, or are using zcat with a compressed file.
IMHO, awk would be the best tool:
awk 'NR==2{ print $3 }' filename
No cat, only one program used, and extra white space is handled automatically.
Using perl would be overkill given the size of the perl shell. Sort of like going to the corner store in your Sherman tank instead of your sedan.
---
Yikes, looking back on the previous messages, I forgot the exit. Shame on me!