-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.

ucr
  • 1

1 Answers1

1

use quotes to stop bash from globbing.

var="A*"
echo "$var"
Jasen
  • 3,761