Bash script that creates a bash script with variables -
i'm writing bash called "newproject" creates second bash script called "compile". both scripts must able take arguments input. problem can not write "$1" compile script - copies contents of newproject's first argument compile script. part of newproject script creates compile script.
echo "#!/bin/bash" > $1/compile echo " if [[ -z '$1' ]]; echo "you missing file names. type in: compile -o executable files." exit 1 fi" >> $1/compile chmod u+x $1/compile
and here output test run of newproject script.
#!/bin/bash if [[ -z 'testproject4' ]]; echo missing file names. type in: compile -o executable files. exit 1 fi
how can change newproject script instead of 'testproject4'
, compile script contains '$1'
?
i use heredoc
cat <<'end' > "$1"/compile #!/bin/bash if [[ -z $1 ]]; echo "you missing file names. type in: compile -o executable files." exit 1 fi end chmod u+x "$1"/compile
when quote heredoc terminator word (cat <<'end'
), quotes entire doc
Comments
Post a Comment