On Tue, Dec 22, 2009 at 10:05 AM, Bryce Stenberg <[email protected]> wrote: > > >> -----Original Message----- >> From: Christopher Sawtell [mailto:[email protected]] >> Sent: Tuesday, December 22, 2009 9:50 AM >> >>echo -n "What is V: "; read V; echo $V > > Cool... > >> >> Remember that bash has a help system for the builtin commands. >> >> help read >> help echo > > Wow, I didn't know that. Cooking with gas now... > > Thanks, bryce. >
Just remember that linux/unix scripts are supposed to be small and do one thing well. Also they are supposed to be able to run non-interactively, ie without user input. If user inpout is required you cannot, for example, run the script from cron or in any other automated way. So pass your variables on the commandline, or read them from a file (the name of the file can be passed on the commandline. If you have a file of the variables, in eg /etc/myscript.conf then it will look like this DISK=sda BACKUPTYPE=removable REMOVABLEDRIVE=/dev/sdc Then in your script you simply read that file in at the start, like: . /etc/myscript.conf # note the dot . at the start of the line, that simply means to read that file. You might also get cleverer and test whether /etc/myscript.conf exists before trying to read it. At the next level you might have /etc/myscript.conf which has global options and ~/.myscript.conf for your user's option overrides[1]. You read in the global file and then the user's file. Settings in the user's file will override the global stuff. [1] its standard to have the user's option file start with a . to make it hidden, ie it doesn't appear in the output of ls unless you do ls -a
