Dependent Origination

How to extract part of a line using grep

Posted on: March 1, 2011

egrep -o ‘[0-9]_[0-9](_[0-9])?’ file

1. use -o for grep to output only the portion of the line that matches

2. use egrep instead of grep so more powerful regular expression can be used

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

March 2011
M T W T F S S
« Feb   Apr »
 123456
78910111213
14151617181920
21222324252627
28293031  

Twitter

Flickr Photos

%d bloggers like this: