I am trying to run a curl command which will need arguments coming in from a pipe
some operation | sort | head -n -2 | curl -s "blah/blah/<argument goes here>/blah"
i cant figure out how to pass each argument one at a time. One way that i found was
some operation | sort | head -n -2 | xargs -l "$" curl -s "blah/blah/$/blah"
but i get
xargs: $: No such file or directory
what does it mean? why is it trying to read $ as a file?
See BashFAQ #1 for the best-practices way to read a string line-by-line:
#!/bin/bash
# ^^^^ - not /bin/sh, or <() will be a syntax error
while IFS= read -r line; do
curl -s "blah/blah/$line/blah"
done < <(some operation | sort | head -n -2)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With