0

I would like to do in bash something I was doing with perl years ago

$4 (value from a script) can have the value "S" or "U"

I have:

DirectoryU="$Directory/*.$2"
DirectoryS="$Directory/area $3/*.$2"

and I want to define "DirectoryC" to something like:

DirectoryC=Directory$4

but there I dont want DirectoryC=DirectoryU (or DirectoryS) I want DirectoryC to have the value of DirectoryU (or DirectoryS) so after I can base my script on $DirectoryC ...

Does it make sense?

Cyrus
  • 84,225
  • 14
  • 89
  • 153
  • 2
    This sounds like a job for indirect expansion (making it a possible duplicate of [this question](https://stackoverflow.com/questions/10820343/how-can-i-generate-new-variable-names-on-the-fly-in-a-shell-script)), or possibly an associative array (using `Directory["U"]` instead of `DirectoryU`, etc). – Gordon Davisson Apr 05 '20 at 23:39
  • 1
    Note that you should probably be using arrays instead of strings (scalar variables in Perl terminology). Trying to store a list of names in a single string will break down the moment any of them has spaces. – Charles Duffy Apr 06 '20 at 00:53

0 Answers0