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!

Remove characters not 6 figs in length and whitespace

Status
Not open for further replies.

maxcrook

Programmer
Jan 25, 2001
210
GB
Hi I have a list of numbers as follows:

012345
45
023567

c00456

I need to remove any numbers that are not of 6 figures plus remove white space.Ive tried this but for some reason it doesnt work (for removing characters of 2figs)

sed '/^[0-9]\{2\}$/d' filename > otherfilename

Any ideas ?
 
This worked for me
Code:
 egrep [0-9]{6} test.file | tr -d ' '>test.op

Columb Healy
 
THANK YOU THANK YOU THANK YOU THANK !
Finally.....

I owe you a beer !
 
Note that my version picks up lines of 6 or greater numbers. Something along the lines of
Code:
tr -d ' ' < test.file | egrep "^[0-9]{6}$" > test.op
will get lines of exactly six numbers

Columb Healy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top