Tim Akinbo's Tumblelog RSS

Hi, I'm Tim Akinbo and this is my tumblelog.

Afrigator

My Popularity (by popuri.us)

Archive

Jan
12th
Wed
permalink

sed

It’s rather interesting that if I wanted to extract the first number from the following line:

  2609  13541 186371 file.csv

Which generated by the command wc and has a variable number of whitespace before the first figure

If I were using a combination of wc, sed and cut, I have to use the following:

wc file.csv | sed -e ‘s/[ ][ ]*/:/g’ | cut -d “:” -f 2

instead of just

wc file.csv | sed -e ‘s/\s+/:/g’ | cut -d “:” -f 2

Comments (View)

blog comments powered by Disqus