Skip to main content
edited tags
Link
Kusalananda
  • 356.1k
  • 42
  • 737
  • 1.1k
formatting
Source Link
user1133275
  • 5.7k
  • 1
  • 22
  • 40

Trying to get bash to combine read and sed to insert a variable into a script. Doesn't necessarily have to be sed but something along those lines.

Something like so:

INTERNAL="`read -p "PATH " path` | sed -i '3i\$INTERNAL="/run/media/blah" blah.sh 

INTERNAL="`read -p "PATH " path` | sed -i '3i\$INTERNAL="/run/media/blah" blah.sh I I could also implement python as well. My project is written in shell but I could use a setup.py script for the initial run.

I'm trying to make a smart script to setup variables during the first run and save them for future usage. In this case it's a path to an external/internal device to backup $HOME. I am going to make the script search for a file: $HOME/.already_ran.txt(hidden dummy file for the script to search for to see if it's been ran before) If it doesn't find that file, it will prompt the user to enter the variables, in this case the paths. I don't want to have them have to open up the script manually and add the variable.

Trying to get bash to combine read and sed to insert a variable into a script. Doesn't necessarily have to be sed but something along those lines.

Something like so:

INTERNAL="`read -p "PATH " path` | sed -i '3i\$INTERNAL="/run/media/blah" blah.sh I could also implement python as well. My project is written in shell but I could use a setup.py script for the initial run.

I'm trying to make a smart script to setup variables during the first run and save them for future usage. In this case it's a path to an external/internal device to backup $HOME. I am going to make the script search for a file: $HOME/.already_ran.txt(hidden dummy file for the script to search for to see if it's been ran before) If it doesn't find that file, it will prompt the user to enter the variables, in this case the paths. I don't want to have them have to open up the script manually and add the variable.

Trying to get bash to combine read and sed to insert a variable into a script. Doesn't necessarily have to be sed but something along those lines.

Something like so:

INTERNAL="`read -p "PATH " path` | sed -i '3i\$INTERNAL="/run/media/blah" blah.sh 

I could also implement python as well. My project is written in shell but I could use a setup.py script for the initial run.

I'm trying to make a smart script to setup variables during the first run and save them for future usage. In this case it's a path to an external/internal device to backup $HOME. I am going to make the script search for a file: $HOME/.already_ran.txt(hidden dummy file for the script to search for to see if it's been ran before) If it doesn't find that file, it will prompt the user to enter the variables, in this case the paths. I don't want to have them have to open up the script manually and add the variable.

Source Link

Second time: Trying to make a script prompt the user to enter a variable for the first time they run the script

Trying to get bash to combine read and sed to insert a variable into a script. Doesn't necessarily have to be sed but something along those lines.

Something like so:

INTERNAL="`read -p "PATH " path` | sed -i '3i\$INTERNAL="/run/media/blah" blah.sh I could also implement python as well. My project is written in shell but I could use a setup.py script for the initial run.

I'm trying to make a smart script to setup variables during the first run and save them for future usage. In this case it's a path to an external/internal device to backup $HOME. I am going to make the script search for a file: $HOME/.already_ran.txt(hidden dummy file for the script to search for to see if it's been ran before) If it doesn't find that file, it will prompt the user to enter the variables, in this case the paths. I don't want to have them have to open up the script manually and add the variable.