Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've got script, it must go through files to get specific lines from them. Filename get from variable, for example $FILENAME and we've got such situation:

cat /path/$FILENAME

but when FILENAME==*.some.file there is a problem. File *.some.file really exist, but cat lists all files by mask *.some.file (first.some.file second.some.file *.some.file fourth.some.file and so on) single quotes on path prevent include of variable.

Any ideas how to cat (or grep) only one *.some.file?

share|improve this question
up vote 6 down vote accepted

Use double quotes. This will expand the variable, but not any embedded wildcards.

cat /path/"$FILENAME"
share|improve this answer
cat "/path/to/$FILENAME"

will not expand * to a glob.

share|improve this answer

cat \*.some.file will escape the * so it's treated as a literal character.

Also cat '*.some.file' will have a similar effect. In both cases, it prevents bash from expanding the * to a list of matching files.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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