I have written two scripts. One is myscipt1.sh
which reads a sequence of integer numbers (provided as arguments) and reports a final number:
[user@pc user] ./myscript1.sh 34 45 67 234
[user@pc user] 1200
In the above example, the script returns 1200
.
Another script myscript2.sh
takes a string as input and returns a sequence of integer numbers:
[user@pc user] ./myscript2.sh a string to provide
[user@pc user] 364 465 786 34 22 1
I want to call myscript1.sh
by passing the result of myscript2.sh
, so I tried:
[user@pc user] ./myscript2.sh my_string | ./myscript1.sh
But I have no luck as myscript1.sh
(wich performs a check on the number of arguments passed, exiting of no arguments are passed) reports that no arguments were passed.
Looks like Bash have problems when I use pipes with scripts I write. How to do?