I have a csv file that contains 3 fields per line.
firstname,lastname,url
I'm trying to access the url via the following pipeline:
grep theName file.csv | cut -d, -f 3
then I want to add another pipe and use the results of the cut command in a curl command like so:
grep theName file.csv | cut -d, -f 3 | curl > result.txt
problem is, when i do the above, the curl command throws an error, i assume because curl doesn't have an argument?
how can I use the result of cut to curl the resulting url? Thanks in advance. =)
Best Answer
Leverage command substitution,
$()
:Here
$()
will be substituted by the STDOUT of the command inside$()
i.e.grep ... | cut -d, -f 3
, as this is done by the shell first so thecurl
command would be finally: