3

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?

Wesley
  • 131

2 Answers2

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
1

Sometimes its easier to remove interactively using a wildcard:

$ rm -i hell*