get literal value of bash variable, without glob expansions or other changes

37 views Asked by At

I have a folder with some xml files in it: 1.xml, 2.xml and so on. Then i am doing:

a=*.xml
echo $a

I am getting list of these xml files like this:

1.xml 2.xml

But then i am doing

a=*.qwe
echo $a

I am getting literal value of a:

*.qwe

Then I am doing

a=ls
echo $a

I am also getting literal value of a: ls

What should i do with a (how to set it properly or how to print it properly?) to always get its literal value even if i have some files with matching extension in this folder? I want always to have *.xml value regardless of files in folder.

Expected behavior: regardless of folder contents, for a=*.xml and a=*.qwe i'd like to have output - *.xml, and *.qwe. For a=ls case i dont care about output, it is just an example which i cannot understand. If i have matching files in folder, i am getting list of files, if there are no matching files - i am getting literal value of mask. But in case of ls which should return anything in any case i am getting literal value too.

0

There are 0 answers