1

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?

marked as duplicate by roaima, chaos, peterph, G-Man, Gilles shell Sep 1 '15 at 22:51

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.

8

You can quote it:

rm "hello world"

or escape the space:

rm hello\ world
  • Why does quoting work? – Wesley Sep 1 '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 1 '15 at 21:29
1

Sometimes its easier to remove interactively using a wildcard:

$ rm -i hell*

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