General
cancel
Showing results for 
Search instead for 
Did you mean: 

can ls file, but cannot read the content

SOLVED
Go to solution
Ogi Prayogo
Occasional Advisor

can ls file, but cannot read the content

hi,

I have a strange file behavour lately. I have log files that are can be listed with ls command. But when i tried to view the content of the log, it responds as if the file did not exist.

For example, the file name is dn.log.2008-10-22

#more dn.log.2008-10-22
dn.log.2008-10-22: No such file or directory

#ls dn.log.2008-10-22
dn.log.2008-10-22 not found

But, if i do:

#ls

the file name appears on the file listing.

Any ideas?
Do not eat anything larger than your head
8 REPLIES
Ogi Prayogo
Occasional Advisor

Re: can ls file, but cannot read the content

Oh, i should add an additional info. when I did the commands above, i logged in as 'root'.

Thanks in advance.
Do not eat anything larger than your head
Suraj K Sankari
Honored Contributor
Solution

Re: can ls file, but cannot read the content

Hi,

I think some extra cheracter will be there in your file, some times hidden space also added with the file name.

Suraj
Dennis Handly
Acclaimed Contributor

Re: can ls file, but cannot read the content

>Suraj: I think some extra character will be there in your file

Right. List with "ls -b".

Steven E. Protter
Exalted Contributor

Re: can ls file, but cannot read the content

Shalom,

Content could be encrypted.

Could be an invisible character in the name.

Try typing the beginning of the name and then escape K to get the rest of the name.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Ogi Prayogo
Occasional Advisor

Re: can ls file, but cannot read the content

Excellent.

Thank you Suraj for hinting the invisible character. Also, thank you Steven for giving me idea on how to go about it. Sadly, i dont understand what 'escape K' is, pardon my ignorance. But what I did was, since i use bash, i used the auto-completion using the tab key.

Dennis, I used 'ls -b' but i have the same result as 'll' or 'ls -al'.
Do not eat anything larger than your head
Dennis Handly
Acclaimed Contributor

Re: can ls file, but cannot read the content

>I used 'ls -b' but i have the same result as 'll' or 'ls -al'.

Then you have spaces:
ll -b | vis -t

With "foo bar" you see "\s" for each space:
... mmm\sDD\sHH:MM\sfoo\sbar
Ogi Prayogo
Occasional Advisor

Re: can ls file, but cannot read the content

Thank you, Dennis.
Do not eat anything larger than your head
Ogi Prayogo
Occasional Advisor

Re: can ls file, but cannot read the content

problem solved. there is a trailing space at the end of the name file.
Do not eat anything larger than your head