Boston Linux & Unix (BLU) Home | Calendar | Mail Lists | List Archives | Desktop SIG | Hardware Hacking SIG
Wiki | Flickr | PicasaWeb | Video | Maps & Directions | Installfests | Keysignings
Linux Cafe | Meeting Notes | Blog | Linux Links | Bling | About BLU

BLU Discuss list archive


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

gawk into an array question



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






BLU is a member of BostonUserGroups
BLU is a member of BostonUserGroups
We also thank MIT for the use of their facilities.

Valid HTML 4.01! Valid CSS!



Boston Linux & Unix / webmaster@blu.org