Reputation: 35
Can someone please help me with this:
As seen below I have a file and directory with the same name as "sp"
How do I delete the file "sp" the one with 44673Bytes size
opxnyd@opxzone1d:/opt/opxnyd/packages/OPXPNY3DB/src/OPXPNYP>ls -alrt
-rwxr-xr-x 1 opxnyd opics 44673 Sep 7 2011 sp
drwxr-xr-x 4 opxnyd opics 1974 May 10 10:22 sp
Upvotes: 1
Views: 120
Reputation: 785058
You cannot have a directory and file with the same name. One of them would be probably having a white-space or some other non printable character in it.
Take this example:
$ touch "sp"
$ mkdir "sp "
$ ls -lrt
total 2
-rw-r--r-- 1 user staff 0 May 18 15:47 sp
drwxr-xr-x 2 user staff 68 May 18 15:47 sp
find -E . -depth 1 -type f -regex "\./sp[ \t]*" -exec rm {} \;
OR following rm command:
\rm -i sp\ *
Upvotes: 0
Reputation: 28762
Try renaming the file (any of them, then) delete the one you don't want (and rename again, if you happed to rename the folder)
Upvotes: 0
Reputation: 555
Like Charlie Martin said, they dont actually have the same name. But you could do a rm sp*
without -r option (directory), deleting only the file.
Upvotes: 0
Reputation: 112356
The trick is that they don't actually have the same name. one of them has a blank or non-printing character in the name. Try ls --escape
to see.
Upvotes: 2