-1

I am wondering is there is a way to assign a regular expression as a character in a string to a variable and not have the regular expression change my variable.

For example: in my directory I am working on I have: A.cc, A.hh, and foo.sh.

In foo.sh:

var=$(A*)

echo $var

I am trying to assign to var specifically A* and not A.cc, A.hh, which is what happening with *.

I am using /bin/sh.

1

use quotes to stop bash from globbing.

var="A*"
echo "$var"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.