I like to start out with something like:perl -F, -lape'join(",",@F[0..3],$F[3],$F[4],@F[4..$#F])' data.txt
To make sure that i am populating @F correctly first, then move on. Once you feel comfortable, you can add inplace editting:perl -F, -MData::Dumper -lape'Dumper \@F' data.txt
perl -F, -lapi.bak -e'$_=join(",",@F[0..3],$F[3],$F[4],@F[4..$#F])' da +ta.txt
UPDATE:
replaced -lane with -lape and dropped print ... silly /me ;)
UPDATE2:
fixed error pointed out by nr0mx and duff ... thanks guys :)
jeffa
L-LL-L--L-LL-L--L-LL-L-- -R--R-RR-R--R-RR-R--R-RR B--B--B--B--B--B--B--B-- H---H---H---H---H---H--- (the triplet paradiddle with high-hat)
In reply to Re: Need help constructing a one-liner
by jeffa
in thread Need help constructing a one-liner
by nr0mx
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |