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

Cyrus
  • 84,225
  • 14
  • 89
  • 153
  • 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. – Charles Duffy Apr 18 '18 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`. – Charles Duffy Apr 18 '18 at 20:16
  • Possibly related: https://stackoverflow.com/q/1921279 – fardjad Apr 18 '18 at 20:17

0 Answers0