Reputation: 57
I want to create a script that needs to take 3 arguments. I want to send the output of the first argument to the second argument and then redirect the final output to a new final. How would I go about doing this?
Upvotes: 0
Views: 49
Reputation: 11992
You can create a script that takes three arguments and from within that script you call you three other commands passing each command one of the arguments.
You would use the script like this:
./mainScript.sh "arg1" "arg 2" "arg3"
Inside the script it would look like this:
#!/bin/bash
commandOne "$1"
commandTwo "$2"
commandThree "$3"
THis is a very simple example. Production ready code would validate the number of arguments like this
if [ "$@" -ne "3" ]
then
echo "must provide three arguments"
exit
fi
Upvotes: 1