I have a CSV file and want to run a command for each line, using the fields of the file as separate arguments.
For example given the following file:
foo,42,red
bar,13,blue
baz,27,green
I want to run the following commands one after another (note that order of arguments in the command may differ from the input file):
my_cmd --arg1 42 --arg2 foo --arg3 red
my_cmd --arg1 13 --arg2 bar --arg3 blue
my_cmd --arg1 27 --arg2 baz --arg3 green
What is the easiest way to achieve this? It seems like it might be possible with xargs but I couldn't figure out how exactly.