Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. 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

This question already has an answer here:

The shellscript is very simple:

retroarch $* -c /tmp/retroarch/Data/retroarch/gambatte.cfg

("retroarch" is another shellscript)

If the filename passed contains spaces it fails:

RetroArch [ERROR] :: Could not read ROM file.
share|improve this question

marked as duplicate by jasonwryan, slm, Hauke Laging, Anthon, manatwork Jun 29 '13 at 14:06

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

See mywiki.wooledge.org/Quotes – jasonwryan Jun 28 '13 at 22:24
up vote 2 down vote accepted

Use quotes.

Instead of

yourcommand some file.name


yourcommand "some file.name"

When using variables, quote them as well.

yourcommand "$filename"
yourcommand "$@"
share|improve this answer
already tried that but did not work! – eadmaster Jun 28 '13 at 22:24
Can you please share the internals of your script? You need to take care internally to maintain double quotes throughout given this variable has spaces in it. – slm Jun 28 '13 at 22:31
oh right, the "retroarch" script was missing double quotes... – eadmaster Jun 28 '13 at 22:36

In general you have to either escape the spaces with backslashes () or wrap the path in either single quotes (') or double quotes (").

$ retroarch "$*" -c /tmp/retroarch/Data/retroarch/gambatte.cfg
share|improve this answer
already tried that, but i always get the error "Could not read ROM file." – eadmaster Jun 28 '13 at 22:29

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