2

This question already has an answer here:

I would like to know how would I rename and change file permissions of a file that contains a space in the name on Linux.

Example

The name of my file is: my file

I have tried mv my%20file my_file

I have also tried chown -R 755 my%20file

but both of these don't work!

marked as duplicate by Anthon, cuonglm, Renan, chaos, slm Jul 22 '14 at 15:32

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.

  • I saw that post but i didn't know how to access bash script so i never worked for me. – Code Jul 22 '14 at 12:27
  • 2
    I wouldn't say so. OP appears to be working at his terminal, not with a Bash script. – Torger597 Jul 22 '14 at 12:48
  • 1
    I agree with @Torger597 -- the dupe is far too complex for a non-scripting user to find intelligible, whereas this one is simple and concise. – goldilocks Jul 22 '14 at 15:18
  • That's correct guys what I was looking for was a simple solution and both answers below from @Gnouc as well as @Michael Kohne was the solution to my question. Thanks guys – Code Jul 22 '14 at 15:22
5

You need to quote file name:

rm 'my file' my_file

or escape space character:

rm my\ file my_file
  • when i do this it tells me Device or resource busy, but im not doing anything with the deveice – Code Jul 22 '14 at 12:26
4

You have to quote or escape the filename. In Bash (the default shell in most distros), you can either use quote marks to enclose the entire name, or a backslash to escape the one space.

rm "my file"
rm my\ file

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