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

Listing 6 digit numbers not 3 1

Status
Not open for further replies.

maxcrook

Programmer
Jan 25, 2001
210
0
0
GB
I have a file that contains data like so

012345
012346
012345
123
012567
109
107

but i want to list only the numbers that are 6 characters in length - any ideas how to remove the ones with 3 characters ?

 
The following sed command removes numbers whith 3 digits (and keep all others).
[tt]sed '/^[0-9]\{3\}$/d' input_file[/tt]

This second command keeps only numbers with 6 digits
[tt]sed -n '/^[0-9]\{6\}$/p' input_file[/tt]


Jean Pierre.
 
Great thanks - i had a horrible feeling it would be a sed command ! Thanks again.

 
If you prefer awk:
awk 'length==6' /path/to/file

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top