extract string

Paul Lussier p.lussier at comcast.net
Tue Jan 10 15:10:01 EST 2006


klussier at comcast.net writes:

> Actually, if you are looking for only lines that contain the string "univ", then you would want to grep for it:
>
> grep univ abc.txt | cut -f3 -d, >> dev.txt.

Why are you appending to dev.txt? (or def.txt even).  Are you assuming
the file already exists and don't want to over-write the contents?


> Paul's example would give you the third field of each line, even if
> they don't have "univ" in them. Now, if you wanted to remove the
> quotes, then you would need something like:
>
>
> grep univ abc.txt | cut -f3 -d, | sed s/\"//g >> dev.txt 

yep, that should work, but no need for the >> when a simple > will do.

-- 

Seeya,
Paul



More information about the gnhlug-discuss mailing list