Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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")

share|improve this question
up vote 3 down vote accepted

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 -
share|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 posting your answer, you agree to the privacy policy and terms of service.

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