A
A
Alexander Semenenko2017-11-07 14:01:45
linux
Alexander Semenenko, 2017-11-07 14:01:45

How to take parameters to run a script from a text file?

Let's say I have a simple test.st script that displays everything that is given to it in the first parameter
#!/bin/bash
echo $1
There is a test.txt file in which "123" is written.
I execute ./test.sh 123 I get 123 I
execute cat test.txt | ./test.sh get nothing.
My script is not formatted correctly, or do I need to redirect in the wrong way?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Andrey Stepanov, 2017-11-07
@semenenko88

./test.sh $(cat test.txt)

B
bbbuuu, 2020-09-03
@bbbuuu

cat test.txt | xargs ./test.sh

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question