Networking | Hardware | Software | Multimedia | System | Unix&Linux | MBA

Home>>Unix&Linux>>Renaming File Called '-z'

Renaming File Called '-z'

teknovision
04-19-2005, 03:10 PM
Hi all!

I did a really silly one.. . I backed up some files and called the result '-z' (without the ').

How can I rename this file without getting the following error:

[root@mac bin]# mv -z backup_19042005
mv: invalid option -- z

Your help would be muchly appreciated, what a pickle I jarred myself in!!

Many thanks for any help!!

.//phil :confused:

hayne
04-19-2005, 03:22 PM
To use Unix command on a file whose name starts with a dash (-), you need to use the full path to the file.
E.g. refer to the file as: ./-z
so to rename it: mv ./-z foo

Of course you could also just use Finder to rename it.

voldenuit
04-19-2005, 03:28 PM
in really screwed-up cases, you can use ls -i to find out the inode-number of the file in question, then use find to delete it.

But hayne's suggestions should take care of the everyday-cases.

teknovision
04-19-2005, 03:52 PM
De-pickled, thank you both so much!!

blb
04-19-2005, 06:37 PM
Another method is the I'm done with switches switch:

mv -- -z file-z

slacker
04-19-2005, 07:27 PM
There are at least 2K+1 answers, where K is the number of Unix geeks in the discussion...

For printable characters, you can always backslash the character:
mv \-z foo

For really wacky stuff, you can use dired mode in EMACS!
emacs .
where . means current directory.

hayne
04-19-2005, 08:15 PM
For printable characters, you can always backslash the character:
mv \-z foo

That doesn't work.
Try it:
touch "-z"
mv \-z foo

slacker
04-20-2005, 12:18 AM
I stand corrected. I completely forgot that - at start of line is the exception because of stdarg processing. -- is the simplest solution..


 

TOP

Windows Server Outsell
Unix Signals And C++ E

For more info

Unix Signals And C++ E
Windows Server Outsell
ssh setup for password
Bash script does not w
esc code 
ARD send unix command 
question about binarie
Scanning mail 
Issuing multiple comma
How do I install Linux

News Archive

/etc/hosts? 
Manually Start a Start
mounting missed hard d
Using Netinfo in Singl
darwin/bsd login probl
system_profiler and fi
Send mail from script 
mounting a drive 
OS X disk first aid ha
system.log shows steal

Related stories:

Single User Boot - A Local Security Risk?
Kbabel install error :(
Shell commands not recognized
how do you remove apps compiled from source? (anything like 'checkinstall' for osx?)
How do I install Linux on Mac
Extracting Pictures (jpegs) From a Windows .exe File
SMBClient question

Copyright@2004-2005 www.zzcoke.com All Right Reserved

advanced web statistics