What is a generalized way to create a bash script from another script.
For instance:
$./script1 arg1 arg2 > script2
$./script2
$arg1 arg2
I can think of a few ways like simply echoing the output but I was wondering if there was a better way or a command I didn't know about and a google search wasn't very helpful.
Thanks in advance for any and all help.
this: source /path/to/script; Or use a bash command to execute it: /bin/bash /path/to/script; The 1st and 3rd methods execute a script as another process, so variables and functions in another script will not be accessible.
Any way of outputting from the first script will work, so echo
or cat
with a heredoc should be fine:
cat << EOT
these will be
the lines of
the second script
EOT
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With