extract string

Ben Scott dragonhawk at gmail.com
Tue Jan 10 13:05:01 EST 2006


On 1/10/06, Whelan, Paul <Paul.Whelan at fmr.com> wrote:
> Like so: cat abc.txt | cut -d, -f3

1.  Randal Schwartz likes to call that UUOC (Useless Use Of cat).  :-)
 You can just do this instead:

      cut -d, -f3 < abc.txt

If you like the input file at the start of the command line, that's legal, too:

     < abc.txt cut -d, -f3

You can read more about UUOC at: http://sial.org/code/shell/tips/useless-cat/

2. The above simply returns the third field.  OP appeared to want only
lines containing "univ".  So:

     cut -d, -f3 < abc.txt | grep univ

3. I'll leave the quote removal as an exercise to the reader.  ;-)

-- Ben "Pedantic" Scott  ;-)



More information about the gnhlug-discuss mailing list