Home > Enterprise >  How to write a variable in a script from another script without sending the value of the variable? [
How to write a variable in a script from another script without sending the value of the variable? [

Time:10-03

Basically, I want to send a variable as $1 in another script without the value it has saved.

#!/bin/bash

echo -e "#!/bin/bash\ncp ~/src/$1" > ~/asset/newfile.sh

So, that in the file newfile.sh it is written:

#!/bin/bash

cp ~/src/$1

CodePudding user response:

You can escape the dollar sign with a backslash:

echo -e "#!/bin/bash\ncp ~/src/\$1"

Or, switch to single quotes:

echo -e '#!/bin/bash\ncp ~/src/$1'
  • Related