awk or grep
am 10.10.2007 00:32:57 von Meeaz
Hi,
I have a text file. The contents are as follows:-
9001
9002
9003
dfdfafdsafd9004fghsjdh
9007
9009
aehewhdhfsd90asdjd
I want to grep ONLY the lines that show 4 digit numbers like 9001,
9002 and NOT 900 appearing in dfdfafdsafd9004fghsjdh or elsewhere.
Pls help
Thanks in Advance
Re: awk or grep
am 10.10.2007 01:00:18 von Stephane CHAZELAS
2007-10-09, 15:32(-07), Meeaz:
> Hi,
>
> I have a text file. The contents are as follows:-
>
> 9001
> 9002
> 9003
> dfdfafdsafd9004fghsjdh
> 9007
> 9009
> aehewhdhfsd90asdjd
>
> I want to grep ONLY the lines that show 4 digit numbers like 9001,
> 9002 and NOT 900 appearing in dfdfafdsafd9004fghsjdh or elsewhere.
[...]
grep -Ex '[0-9]{4}' < file.text
--
Stéphane
Re: awk or grep
am 10.10.2007 01:09:34 von Bill Marcum
On 2007-10-09, Meeaz wrote:
> Hi,
>
> I have a text file. The contents are as follows:-
>
> 9001
> 9002
> 9003
> dfdfafdsafd9004fghsjdh
> 9007
> 9009
> aehewhdhfsd90asdjd
>
> I want to grep ONLY the lines that show 4 digit numbers like 9001,
> 9002 and NOT 900 appearing in dfdfafdsafd9004fghsjdh or elsewhere.
>
> Pls help
>
> Thanks in Advance
>
grep '^[[:digit:]][[:digit:]][[:digit:]][[:digit:]]$'
Re: awk or grep
am 10.10.2007 02:16:49 von Meeaz
On Oct 9, 7:00 pm, Stephane CHAZELAS wrote:
> 2007-10-09, 15:32(-07), Meeaz:> Hi,
>
> > I have a text file. The contents are as follows:-
>
> > 9001
> > 9002
> > 9003
> > dfdfafdsafd9004fghsjdh
> > 9007
> > 9009
> > aehewhdhfsd90asdjd
>
> > I want to grep ONLY the lines that show 4 digit numbers like 9001,
> > 9002 and NOT 900 appearing in dfdfafdsafd9004fghsjdh or elsewhere.
>
> [...]
>
> grep -Ex '[0-9]{4}' < file.text
>
> --
> St=E9phane
Thanks a lot!
Re: awk or grep
am 10.10.2007 04:36:15 von Henry
On Oct 10, 11:32 am, Meeaz wrote:
> Hi,
>
> I have a text file. The contents are as follows:-
>
> 9001
> 9002
> 9003
> dfdfafdsafd9004fghsjdh
> 9007
> 9009
> aehewhdhfsd90asdjd
>
> I want to grep ONLY the lines that show 4 digit numbers like 9001,
> 9002 and NOT 900 appearing in dfdfafdsafd9004fghsjdh or elsewhere.
>
> Pls help
>
> Thanks in Advance
awk 'length == 4' text.file
Re: awk or grep
am 10.10.2007 09:40:05 von cichomitiko
Meeaz wrote:
> Hi,
>
> I have a text file. The contents are as follows:-
>
> 9001
> 9002
> 9003
> dfdfafdsafd9004fghsjdh
> 9007
> 9009
> aehewhdhfsd90asdjd
>
> I want to grep ONLY the lines that show 4 digit numbers like 9001,
> 9002 and NOT 900 appearing in dfdfafdsafd9004fghsjdh or elsewhere.
[...]
With zsh:
print -l ${(M)$(
Dimitre