Mar 19, 2004 #1 maxcrook Programmer Jan 25, 2001 210 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 ?
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 ?
Mar 19, 2004 1 #2 aigles Technical User Sep 20, 2001 464 FR 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. Upvote 0 Downvote
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.
Mar 19, 2004 Thread starter #3 maxcrook Programmer Jan 25, 2001 210 GB Great thanks - i had a horrible feeling it would be a sed command ! Thanks again. Upvote 0 Downvote
Mar 19, 2004 #4 PHV MIS Nov 8, 2002 53,708 FR 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 Upvote 0 Downvote
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