I have a CSV file like:Name,Age,AddressDaniel Dvorkin,28,Some Address St. 1234(... N ...)Foo Bar,90,Other Address Av. 3210And I have a command that take this parameters:./mycommand --name=Daniel Dvorkin --age=28 --address=Some Address St. 1234What is the easiest way to run mycommand for each line of the CSV?
Using CSV line as command parameters
shell;text processing;pipe;csv
That's pretty easy:sed '1d;s/\([^,]*\),\([^,]*\),\([^,]*\)/.\/mycommand --name=\1 --age=\2 --address=\3/e' file.csv1d will delete caption line.s command will modify the string like in your examplee in the end of s command will execute the string. this is GNU extension, so if you don't have GNU sed, you can use xargs instead e:sed '1d;s/\([^,]*\),\([^,]*\),\([^,]*\)/.\/mycommand --name=\1 --age=\2 --address=\3/' file.csv | xargs