extract string
klussier at comcast.net
klussier at comcast.net
Tue Jan 10 16:09:01 EST 2006
-------------- Original message ----------------------
From: Paul Lussier <p.lussier at comcast.net>
> 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?
>
That is exactly what I was thinking. Even if it isn't being appended to, The result is essentially the same. Unless, of course, you want to over-write the file. Then that would work out to well. It's better to be safe then sorry :-) Besides, I've been doing a log of this sort of thing in the last few days, and the >> just sort of rolled off my fingertips.
> > 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.
What? Two redirects are better then one, right :-)
C-Ya,
Kenny
More information about the gnhlug-discuss
mailing list