Super User is a question and answer site for computer enthusiasts and power users. 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

Suppose I have a bash shell script called that need on argument as input.

But I want the content of the text file called text.txt to be that argument.

I have tried this but it does not work:

# cat text.txt | ./

Do we have a way to do it?

share|improve this question
up vote 8 down vote accepted

Command substitution.

./ "$(cat text.txt)"
share|improve this answer

You can use pipe output as a shell script argument.

Try this method:

cat text.txt | xargs -I {} ./ {}
share|improve this answer

If you have more than one command in the file, consider using xargs or parallel, e.g.

xargs -d '\n' < text.txt
parallel -j4 < text.txt
share|improve this answer


 # cat comli.txt

 # cat
 which $1

 # for i in `cat comli.txt` ; do ./ $i ; done

so you can enter the values one by one to from comli.txt.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .