I made a text file called hello world
in my home directory. Via the shell I am trying to remove it with the rm
command. However, when I execute rm hello world
the shell thinks that I am trying to delete two separate files, one called "hello" and the other called "world." How do I go about doing this correctly?
Asked
Active
Viewed 3,860 times
3

Wesley
- 131
2 Answers
10
You can quote it:
rm "hello world"
or escape the space:
rm hello\ world

Andy Dalton
- 13,993
-
Why does quoting work? – Wesley Sep 01 '15 at 19:40
-
The shell works with "tokens" that are usually whitespace delimited. Quotes (either single or double) creates a token that starts with the character following the beginning quote and ends with the character preceding the end quote. Like @josten mentioned, make the shell pass a single token containing "hello world" instead of two tokens containing "hello" and "world". – Andy Dalton Sep 01 '15 at 21:29