0

I have a set of directories listed inside a text file as

DIR_A= (name of directory 1) 
DIR_B= (name of directory 2)
....

I have a second script to which I would like to pass an argument like sh Scriptname varname where varname could be A, B, ...

Scriptname sources the initial text file and I would like this script to accept the passed varname (using $1) to echo DIR_varname.

Any ideas? TIA

3
  • 1
    Details matter. If there's a space between the = and the name, that would directly trigger a bug. Make sure your examples fit the same form as your real data. Commented Apr 18, 2018 at 20:15
  • Also, you're using the bash tag, but you're saying that your script is being run with sh. These are very different shells -- if you want to use bash-only features, your script must be run with bash scriptname, not sh scriptname. If you want help writing a script that runs with sh, tag the question sh, not bash. Commented Apr 18, 2018 at 20:16
  • Possibly related: stackoverflow.com/q/1921279 Commented Apr 18, 2018 at 20:17

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.