Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

bash: how _best_ to create a script from another script

Tags:

bash

shell

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.

like image 961
Randall Hunt Avatar asked Feb 07 '10 21:02

Randall Hunt


People also ask

How do you call one script from another script in bash?

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.


1 Answers

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
like image 142
Jakob Borg Avatar answered Sep 27 '22 00:09

Jakob Borg