sudo rm (filename with spaces between two words)
jwshea at gmail.com
Wed Oct 25 02:03:00 BST 2006
On Wed, 25 Oct 2006 03:00:53 +1000
From: Peter Garrett <peter.garrett at optusnet.com.au> wrote:
> On Tue, 24 Oct 2006 11:59:56 -0400
> smithveg <smithveg at gmail.com> wrote:
> > Hello,
> > Normally, i just use the 'sudo rm filenames' to delete a file. But i can not
> > delete a filename like 'file to you.odt'
> > When i try to create launcher in desktop, i can noticed the command also
> > have the space inthe filename. But if i write in terminal, it prompt me file
> > not found.
> > sudo rm file to you.odt ---> can not find the file. Why?
> Linux/Unix doesn't like spaces in file names :) You can usually
> tab-complete the name like this:
> sudo rm file <tab>
> or, you can put the file name in quotes like:
> sudo rm "file to you.odt"
> There is a reason for this, if you think about it - commands, options and
> arguments are separated with spaces on the command line, so it's tricky
> for the bash shell to guess which spaces meant what.... If there is a space
> it assumes the next word is a file name, so it interprets file to you as 3
> files ( file , to, you ) . Since those files don't exist, it complains ;-)
> When creating files I usually separate words using dots - like
> file.to.you.odt . You might prefer to use underscores, or hyphens.
You can also escape special characters (incl. whitespace) by using a \
i.e. rm file\ to\ you.odt
Joel Shea <jwshea at gmail.com>
GPG Key ID: 0xA992856D
More information about the ubuntu-au