Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

simple sed -n problem

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Friends , a stupid question.
Following is the file of 9 lines (sample.txt) :
900
12356
2.1
3.14159265
87878787
0.25


a

if i give command ,
sed -n -e '/900*/p' sample.txt
I get output of just one line ,
900

Now if I give command ,
sed -n -e '/[09]*/p' sample.txt
I get all the lines in output ,
900
12356
2.1
3.14159265
87878787
0.25


a

Why is that ?? I am expecting combination of only 0 & 9 in output .
Please advice.
 
sed -n -e '/[09]/p'

By specifying '*' you're saying 'ZERO or more occurences of the preceeding character' [0 or 9 in your case]. It outputs everything because of the 'ZERO' case. vlad
+---------------------------+
|#include<disclaimer.h> |
+---------------------------+
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top