Perl: Working with columnar data
I have a text file of data that is in whitespace separated columns that I need to work with. Perl has a command line option -a to enable auto-splitting the input into an array called @F. Using a Perl one-liner you can automatically split at whitespace separation like this:
cat /tmp/file_list.txt | perl -lane 'print "mv $F[3] $F[1]"'
This will output mv commands to rename the file in the 4th column to the 2nd column.
More information available in perlrun.
Tags:


