[TriLUG] how to grep

Mike M linux-support at earthlink.net
Thu Feb 6 19:36:52 EST 2003


On Thursday 06 February 2003 18:02, Mike Norwood wrote:
> Hi,
>
> I need to ask a question of this wonderful and knowledgeable group.  I
> need to grep a certain number from a file, but only when it is a certain
> location on each line, for example I want to find 12345678901, but only if
> it is in position 46 through 56 on each line in the file, not if it is in
> any other position.  What is the simplest way to tell grep to only pull
> out these records and not other matches not in position 46 through 56.

man cut

first run file through cut and then through grep or egrep

cut -c 46-56 | egrep 12345678901 > out.txt

-- 
Mike M.



More information about the TriLUG mailing list