Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Rename / remove directory 1

Status
Not open for further replies.

christiniaroelin

Programmer
Sep 15, 2004
26
US
Folks,

Im trying to rename or remove a directory named '-ltr' which was created in error. The problem being faced is that when used with "mv" / "rmdir" command , it treats the dir name -ltr as flag...is there any way to get arround this??

Thanks
Chris
 
Or simply:
rmdir ./-ltr

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Thanks for your replies..but still have the undesired output
rmdir: ./-ltr: No such file or directory

regrads,
chris
 
And this ?
rm -ri ./*-ltr*

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
if created in error, has it any ivisible characters added to the name ?

rm -rf "-l<press tab to complete name> and close " [return]

______________________________________________________________________
There's no present like the time, they say. - Henry's Cat.
 
or use: rmdir \-ltr
or: rmdir '-ltr' # single quotes

If the directory isn't empty use rm -r instead of rmdir.

The bottom line to all the answers, is to find a way to escape the minus from the shell.

Theophilos.

-----------

There are only 10 kinds of people: Those who understand binary and those who don't.
 
To find the real name (including non-printable characters):

cd /parent/dir
find . -type d -ls|grep ltr|od -xc

If you can't figure it out, post the output of that find command string and I'll have a look.


HTH,

p5wizard
 
Easier way to find non-printable characters is the [tt]-b[/tt] option of [tt]ls[/tt]. That prints non-printable characters in octal.
Code:
ls -lab *l*t*r*
Hope this helps.
 
-b option of ls does not show/highlight space characters...

HTH,

p5wizard
 
Hey, not easy!
I thought
Code:
rmdir .ltr
would do the job, if no other directory would match .ltr
But I had to do:
Code:
find . -type d -name "?ltr" -exec rm -rf "{}" \;
with the same assumtion: no other directory matching *ltr*.

seeking a job as java-programmer in Berlin:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top