How can I use the output of sed in another script?

For example (this doesn't work):

sed -n "$COUNTER",1p /domains.csv | wget


sed -n "$COUNTER",1p /domains.csv > /myScript.sh

As far as I know > lets me take the output and put it in a file, I'm just unsure of how to use this output as an argument in another script.

(I am aware I can declare the output as a variable, and then use it on the next line. I'm interested in how to do this as one "command")


The | takes output and redirects it into stdin. wget needs a command line argument, not stdin so you want to pipe to xargs which will build a command line from stdin.

sed -n "$COUNTER",1p /domains.csv | xargs wget

Alternatively you can tell wget to take input on stdin

sed -n "$COUNTER",1p /domains.csv | wget -i -
| improve this answer | |
  • Aha!! thanks so much, that'll do it. Thanks also for the explanation – d-_-b Dec 29 '13 at 3:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.