Reputation: 1292
I have a program that takes a variable number of arguments and I want to run the program in parallel with one instance for each line of an input file. The input file is comma separated with some missing columns at the end of some rows. How can I instruct GNU parallel to skip the parameter substitution when the column is missing?
A,B,C,D,E
A,B,C,D
A,B,C
parallel -a $1 --trim lr --colsep ',' echo {1} {2} {3} {4} {5}
A B C D E
A B C D {5}
A B C {4} {5}
A B C D E
A B C D
A B C
Upvotes: 2
Views: 1414
Reputation: 6107
If you just want to replace commas for another char (like space), simply:
cat YOUR_FILE | parallel --pipe sed \'s/,/ /g\'
Wher the " " between the "," and "g" is the character that will replace your comma.
If you also want to do some transformations managing columns, try awk
.
Upvotes: 0