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
.
var=A*; printf "%s\n" "$var"
. see: What is $() in a command?, Why does my shell script choke on whitespace or other special characters? and Why is printf better than echo? – Evgeny Aug 09 '15 at 04:53