How to remove a directory called "--"


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users How to remove a directory called "--"
# 1  
Old 01-13-2009
How to remove a directory called "--"

I need to remove a directory called "--"". But it seems "--" linked to /export/home/usr1, which I do not want to delete. How to rm "--" safely?

Quote:
usr1@hostname1:/xxx/xxxx/xx/xxxx/dir1$ ls -l
drwx--S--- 2 usr1 group1 96 Aug 29 2005 --

usr1@hostname1:/xxx/xxxx/xx/xxxx/dir1$ cd --
usr1@hostname1$ pwd
/export/home/usr1
The OS is Solaris 9.
Thanks.
# 2  
Old 01-13-2009
Try to delete it using a ftp client.
# 3  
Old 01-13-2009
perl -e 'rmdir("--")'
# 4  
Old 01-13-2009
First thing that I'd recommend, is to make a backup of /export/home/usr1

Then, from the /XXX/XXXX/XX/XXXX/dir1 directory, run this command:
Code:
rm -rf ./--<filename>

...
If it was a file, you could easily delete it via it's inode number
Code:
ls -il
find . -inum <number>| xargs rm


Last edited by avronius; 01-13-2009 at 01:01 PM.. Reason: removed incorrect recommendation
# 5  
Old 01-13-2009
Also the -- thing when given to cd results in the current directory. Your directory is not a link.
# 6  
Old 01-13-2009
quite easy

rm doesn't accept -- on first position, same as touch, rmdir and almost every other standard command


so user it on second place

rm blablo --

blablo must not exist

also for creating such files, you can use "touch blablo --"

for some jokes with colleagues Smilie
öhm I mean for better understanding!!!!

Edit: rmdir, not rm
# 7  
Old 01-13-2009
Thanks a lot!

As you said, "--" is not linked to /export/home/usr1.

rm -rf ./-- works!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. AIX

Apache 2.4 directory cannot display "Last modified" "Size" "Description"

Hi 2 all, i have had AIX 7.2 :/# /usr/IBMAHS/bin/apachectl -v Server version: Apache/2.4.12 (Unix) Server built: May 25 2015 04:58:27 :/#:/# /usr/IBMAHS/bin/apachectl -M Loaded Modules: core_module (static) so_module (static) http_module (static) mpm_worker_module (static) ... (3 Replies)
Discussion started by: penchev
3 Replies

2. Linux

Read only access for Group called "Developers" to all folders on the Centos 6.6

Linux Gurus, I need to provide Read only access for particular group of users, they should have Read only access to entire server except their Home directory. I tried using setfacl that's not helping. Can you please suggest is there any other alternate way to address this request. Your help is... (5 Replies)
Discussion started by: shekar777
5 Replies

3. UNIX for Dummies Questions & Answers

Problems with "exit" called from function in bourne script

Hi everyone. #!/sbin/sh EXITING() { umount /FOLDER rm -Rf /FOLDER echo "EXIT" exit 0 } EXITING echo "OK" (8 Replies)
Discussion started by: vacadepollo
8 Replies

4. Shell Programming and Scripting

how to use "cut" or "awk" or "sed" to remove a string

logs: "/home/abc/public_html/index.php" "/home/abc/public_html/index.php" "/home/xyz/public_html/index.php" "/home/xyz/public_html/index.php" "/home/xyz/public_html/index.php" how to use "cut" or "awk" or "sed" to get the following result: abc abc xyz xyz xyz (8 Replies)
Discussion started by: timmywong
8 Replies

5. Shell Programming and Scripting

Remove file called "-X"??

Hi all, So I have found a file literally called "-X" in a folder, that is preventing me from using any meaningful commands in that folder because, as I understand it, at command runtime it will convert any wildcard characters into matching filenames, thus a command such as: ls *Ends up actually... (7 Replies)
Discussion started by: dan-e
7 Replies

6. Shell Programming and Scripting

awk command to replace ";" with "|" and ""|" at diferent places in line of file

Hi, I have line in input file as below: 3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL My expected output for line in the file must be : "1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL" Can someone... (7 Replies)
Discussion started by: shis100
7 Replies

7. Shell Programming and Scripting

Delete files older than "x" if directory size is greater than "y"

I wrote a script to delete files which are older than "x" days, if the size of the directory is greater than "y" #!/bin/bash du -hs $1 while read SIZE ENTRY do if ; then find $1 -mtime +$2 -exec rm -f {} \; echo "Files older than $2 days deleted" else echo "free Space available"... (4 Replies)
Discussion started by: JamesCarter
4 Replies

8. UNIX for Advanced & Expert Users

All alias in .profile lost when "script" command is called

Hi, I was trying to call "script <an ip add>" command from .profile file to log everything whenever anyone logs in to this user. I did the following at the end of .profile. 1) Extracted the IP address who logged in 2) Called script < ip add> . The problem I am facing is all, aliases etc. written... (3 Replies)
Discussion started by: amicon007
3 Replies

9. Windows & DOS: Issues & Discussions

Samba (SMB) client fails: "Called name not present"

Hi, I issue smbclient on a Linux REd hat server : smbclient -L ***.16.0.42 -U domaine/Administrator Password: Domain= OS= Server= Domain= OS= Server= Sharename Type Comment --------- ---- ------- IPC$ IPC IPC distant ... (0 Replies)
Discussion started by: big123456
0 Replies

10. Shell Programming and Scripting

How to remove "New line characters" and "spaces" at a time

Dear friends, following is the output of a script from which I want to remove spaces and new-line characters. Example:- Line1 abcdefghijklmnopqrstuvwxyz Line2 mnopqrstuvwxyzabcdefghijkl Line3 opqrstuvwxyzabcdefdefg Here in above example, at every starting line there is a “tab” &... (4 Replies)
Discussion started by: anushree.a
4 Replies
Login or Register to Ask a Question