gawk into an array question
Eric Chadbourne
EChadbourne-3av5VAs6qClGBRGhe+f61g at public.gmane.org
Tue Jan 27 11:54:01 EST 2009
> Hello:
>
> This is not the answer to the question, but another way, as
> is the way in Unix.
>
> If one is rusty with awk, this is the perl one-liner that
> gets at the first argument:
>
> $ perl -F, -lane 'print $F[0]' test.csv
> catname1.dat
> foo.txt
> foo1.txt
> foo2.txt
> foo3.txt
> foo4.txt
>
> -lane is easy to remember, kind of like lanes of traffic. I
> had to look up -F that defines the separator, in this case a
> comma. The variable created by this process is the array @F,
> so I guess in makes sense to make the separator option with
> -F. Inside the single quotes, one could do more Perl string
> manipulation if needed, like joining with the 3rd argument
> $F[2], if needed.
>
> Doug
always neat to see another way to get the job done. i haven't played with pearl yet. so many toys, so little time...
thanks, eric c.
More information about the Discuss
mailing list