Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Removing directory with leading hyphen from root directory Post 302934069 by edstevens on Wednesday 4th of February 2015 11:44:25 AM
Old 02-04-2015
Removing directory with leading hyphen from root directory

I know that this basic question has been asked many times and solutions all over the internet, but none of the are working for me. I have a directory in the root directory, named "-p".

Code:
[root@vbpsdev /]# ls -l /
total 198
<snip>
drwxr-xr-x   4 root   root      4096 Dec  3 14:18 opt
drwxr-xr-x   2 root   root      4096 Dec  2 14:09 -p
dr-xr-xr-x 129 root   root         0 Feb  4 08:33 proc
<snip>

Several different variations on trying to delete it.

Code:
[root@vbpsdev /]# pwd
/
[root@vbpsdev /]# rm /-p
rm: cannot lstat `/-p': No such file or directory
[root@vbpsdev /]# rmdir /-p
rmdir: /-p: No such file or directory
[root@vbpsdev /]# rm -fR -- -p
[root@vbpsdev /]# ll
<snip>
drwxr-xr-x   4 root   root      4096 Dec  3 14:18 opt
drwxr-xr-x   2 root   root      4096 Dec  2 14:09 -p
dr-xr-xr-x 129 root   root         0 Feb  4 08:33 proc

Try to remove by inode. First, find the inode
Code:
[root@vbpsdev /]# ls -li
<snip>
1702273 drwxr-xr-x   4 root   root      4096 Dec  3 14:18 opt
1767745 drwxr-xr-x   2 root   root      4096 Dec  2 14:09 -p
      1 dr-xr-xr-x 129 root   root         0 Feb  4 08:33 proc

Then use 'find' for a 'rm', first, use an 'ls' instead of 'rm', to confirm what the 'find' finds

Code:
[root@vbpsdev /]# find . -inum 1767745 -exec ls -li {} \;
find: ./proc/5734/task/5734/fd/4: No such file or directory
find: ./proc/5734/task/5734/fdinfo/4: No such file or directory
find: ./proc/5734/fd/4: No such file or directory
find: ./proc/5734/fdinfo/4: No such file or directory
total 0

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

removing a directory

all - I'm trying to delete this directory with no success. This was placed in my folder by a test script I wrote for beginners... drwxr-xr-x 2 myaddress ssusr 512 Dec 22 16:10 $x+1 Here is the message I receive - I've tried every command possible to remove it: rmdir:... (7 Replies)
Discussion started by: da_curtain
7 Replies

2. UNIX for Advanced & Expert Users

Removing all file for the particular directory

i want remove all the files from below directory Available directory foa/commprog/data foa/commprog/a foa/commprog/b mfoa/commprog/data mfoa/commprog/a mfoa/commprog/c dfoa/commprog/d There are more folders like this i want to remove the the file from only /data i need only... (3 Replies)
Discussion started by: kingganesh04
3 Replies

3. UNIX for Dummies Questions & Answers

removing the files but not the directory

How would i rmeove all the files in the directory but still keep the directory? (5 Replies)
Discussion started by: JamieMurry
5 Replies

4. Shell Programming and Scripting

ksh function getopts get leading underscore unless preceded by hyphen

If I call my function with grouped options: "logm -TDIWEFO 'message' ", then only the "T" gets parsed correctly. The subsequent values returned have underscores prefixed to the value: "_D", "_I", etc. If I "logm -T -DIWEFO 'message' ", the "T" and the "D" are OK, but "I" through "O" get the... (2 Replies)
Discussion started by: kchriste
2 Replies

5. UNIX for Dummies Questions & Answers

How to display only Owner and directory/sub directory names under particular root

hai, I am new to Unix, I have a requirement to display owner name , directory or sub directory name, who's owner name is not equal to "oasitqtc". (here "oasitqtc" is the owner of the directory or sub directory.) i have a command (below) which will display all folders and sub folders, but i... (6 Replies)
Discussion started by: gagan4599
6 Replies

6. Shell Programming and Scripting

Untar specific directory and strip leading directories

Ok so I know the title was probably confusing so here goes: I have a tarball (gzipped) that has a nested directory structure . For example: my.tar.gz (contents) --- ------ --------- ------------ --------------- ... (2 Replies)
Discussion started by: DC Slick
2 Replies

7. Shell Programming and Scripting

how to remove leading directory from line in filename?

i have a process that receives files similar to below. these are files obviously generated on a windows machine that are submitted to a linux cluster. the one thing they have in common is the leading c:\any-number-of-leading-dirs\filename.xxx. is there a way to re-create/modify the file to remove... (3 Replies)
Discussion started by: crimso
3 Replies

8. Shell Programming and Scripting

Removing hyphen from beginning and end of a word only.

It is very simple to remove a hyphen from a word anywhere in that word using a simple sed command (sed -i 's/-//g' filename), but I am not able to figure out how to do this: For example, apple -orange tree pipe- banana-shake dupe- What my output should look like: apple orange tree... (1 Reply)
Discussion started by: shoaibjameel123
1 Replies

9. UNIX for Beginners Questions & Answers

Deleting directory with leading hyphen in name

I asked this question last month in Stack Exchange (linux - delete directory with leading hyphen - Server Fault) and none of the answers supplied worked. I have somehow created a directory with a leading hyphen and cannot get rid of it. # ls -li | grep p 2621441 drwxr-xr-x. 2 root root... (4 Replies)
Discussion started by: edstevens
4 Replies

10. Solaris

SunOS confusing root directory and user home directory

Hello, I've just started using a Solaris machine with SunOS 5.10. After the machine is turned on, I open a Console window and at the prompt, if I execute a pwd command, it tells me I'm at my home directory (someone configured "myuser" as default user after init). ... (2 Replies)
Discussion started by: egyassun
2 Replies
named-checkconf(1M)					  System Administration Commands				       named-checkconf(1M)

NAME
named-checkconf - named configuration file syntax checking tool SYNOPSIS
named-checkconf [-v] [-t directory] filename DESCRIPTION
The named-checkconf utility checks the syntax, but not the semantics, of a named configuration file. OPTIONS
The following options are supported: -t directory Change the root directory to directory so that include directives in the configuration file are processed as if run by a named configuration whose root directory has been similarly changed. -v Print the version of the named-checkconf program and exit. OPERANDS
The following operands are supported: filename The name of the configuration file to be checked. If not specified, it defaults to /etc/named.conf. EXIT STATUS
0 No errors were detected. 1 An error was detected. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | |Availability |SUNWbind9 | |Interface Stability |External | +-----------------------------+-----------------------------+ SEE ALSO
named(1M), named.conf(4), attributes(5) BIND 9 Administrator Reference Manual NOTES
Source for BIND9 is available in the SUNWbind9S package. SunOS 5.10 15 Dec 2004 named-checkconf(1M)
All times are GMT -4. The time now is 04:04 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy