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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I select specific records in a file

Status
Not open for further replies.

Tison

Programmer
May 12, 1999
216
CH
I have a file with many records (fixed format).
I need to select all records that start with 4 in the third column.
example
"fred",123,400,"Some text"
"A",0,456,"Text"
"A",0,100,"Stuff"
"A lot of text",99999,490,"A lot of text"
 
Hi,
If the fiels of your file are separated with comma ','
then try this awk script
awk -F, '$3 ~ /4.*/ {print $0}' /path/to/your/file

-F indicate the field separator assumed to be comma here
 
Hi,

If the fiels of your file are separated with comma ','
then try this awk script

To be more precise, use ^4.* ( varet indicates begin with )

awk -F, '$3 ~ /^4.*/ {print $0}' /path/to/your/file

-F indicate the field separator assumed to be comma here
 
Thats exactly it,,,,thanks a ton.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top