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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

LS show file, but I cant remove it! 2

Status
Not open for further replies.

Pinho

IS-IT--Management
Aug 19, 2003
20
US
Hi, guys.
Help me in this situation:
If I execute
# ls /dir/dir2
# cd /dir/dir2;ls
# cd /dir; ls dir2
Too many ways to show the content of /dir/dir2, ok?
A file called abc.txt is showed. But if I type
# ls /dir/dir2/abc.txt
# cd /dir/dir2;ls abc.txt
# cd /dir; ls dir2/abc.txt
The result is:
ls: 0653-341 The file abc.txt does not exist.
I can try rm, find, touch, cp, mv the situation is the same. With the name file, it not works.
To save my soul, I moved the directory (mv /dir/dir2 /dir/dir2.old) and created another with the same name (mkdir /dir/dir2). So, my applicatin is working.
The file abc.txt was moved to dir2.old
Now, to understand wath happened, I apologize your help.

Sorry for my English. I hope, at least, you undestand my problem. ;-)

Luis Henrique Pinho
No Orkut - Unix Brasil
 
Hi
Mybe the name of your file abc.txt contains some non-printing character.

Here is an example :
Code:
/tmp:ls abc*
abc.txt
/tmp:ls abc.txt
abc.txt not found
/tmp:ls abc.txt*|od -xc
0000000     6162    632e    7478    7416    0a00
           a   b   c   .   t   x   t 026  \n
0000011
/tmp:
Here, we see with od command all the characters in the name of the file
 
try ls -lb to display non printing characters
 
Thanks for all!!!

aau:
When I execute:
#ls -l abc* the result is
abc.txt
# ls abc.txt |od -xc
ls: 0653-341 The file abc.txt does not exist.
0000000
#

Gloups:
# ls -lb abc.txt
ls: 0653-341 The file abc.txt does not exist.
#
#ls -lb abc*
-rw-r--r-- 1 user group 85 May 27 10:00 abc.txt

Very weird.


Luis Henrique Pinho
No Orkut - Unix Brasil
 
Strange one
How about if you try `ls -lb abc.t*` or `ls -lb abc.txt*`
Just to see at which point it starts complaining.
Something must be wierd in the internal representation of the filename
Does `ls -lb "abc.txt"` do the same thing?


"If you always do what you've always done, you will always be where you've always been."
 
Hi,

Use the * (star) in the command :

Code:
ls abc.txt* |od -xc

to see if your file has non printing characters in its name.

 
or type

Code:
ls | grep abc | od -xc

My guess is that there is a space character (or more than one) at the end of the filename, hard to pick up: ls -b doesn't highlight spaces in a filename.

try

Code:
ls -l "abc.txt "


HTH,

p5wizard
 
<b>aau</b>. Sorry, in your first suggestion, I forgot to put ls abc.txt* (<b>the * in the end of the filename</b>)


I think that´s the point:
# ls -lb abc.txt* |od -xc
0000000 2d72 772d 722d 2d72 2d2d 2020 2031 2063
- r w - r - - r - - 1 c
0000020 746d 3631 3320 2020 636f 6e74 726f 6c6d
t m 6 1 3 c o n t r o l m
0000040 2020 2020 2020 2020 2038 3520 4d61 7920
8 5 M a y
0000060 3237 2031 303a 3030 2042 5257 5350 4d54
2 7 1 0 : 0 0 B R W S P M T
0000100 5a39 3938 3920 2020 2020 2020 2020 2020
Z 9 9 8 9
0000120 2020 2020 2020 2020 2020 2020 2020 2020

0000140 2020 2020 2020 2020 2020 200a
\n
0000154

Please, translate it to me... ;-)
To help you translate it:
The real filename is <b>BRWSPMTZ9989</b>, I was using abc.txt to do more easy to write the name.

Luis Henrique Pinho
No Orkut - Unix Brasil
 
OK, your filename is "BRWSPMTZ9989 "

There are 32 space chars at the end of the filename

try the following command (again)

Code:
ls -l "BRWSPMTZ9989  *"

HTH,

p5wizard
 
BINGO!!! Very, very good!!
The right number is 38.
There are 38 spaces at the end.
See it:
#ls -l BRWSPMTZ9989??????????????????????????????????????
-rw-r--r-- 1 ctm613 controlm 85 May 27 10:00 BRWSPMTZ9989

See it too:
vi BRWSPMTZ9989??????????????????????????????????????

NODEID BRWSPMTZ9989
AGSTAT R
FIRST_SET 20050527100020
LAST_UPD 20050101000000
~
~
"BRWSPMTZ9989 " 4 lines, 85 character

Thanks aau, p5wizard, rzs0502...
Thanks for all!!!


Luis Henrique Pinho
No Orkut - Unix Brasil
 
Have you tried an ls -li abc.* to see what the inode number is?

Then try a find . -inum <inode number> exec ls {} \;

To see if it lists the file.

If it does then you can remove it using the find command above but substituting ls with rm -f.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top