1825775 Members
2050 Online
109687 Solutions
New Discussion

Re: Problems with ls

 
SOLVED
Go to solution
Jeff Picton
Regular Advisor

Problems with ls

Hi

I have a listing of files in a directory. When I use ls to list the files, the list appears as output.

However, when I try to ls an INDIVIDUAL file the file is not recognised. This applies to the cat , file commands also.

Can anyone help ?

Cheers

Jeff
15 REPLIES 15
Michael Schulte zur Sur
Honored Contributor

Re: Problems with ls

Hi,

when you mean not found, try ls -lb to see any invisable characters in the name.

Michael
Jeff Picton
Regular Advisor

Re: Problems with ls

Hi

When I do that I get the following :-

root@telesto[dublin_out1] ls -lb SNNL54020700_20040202_072325
SNNL54020700_20040202_072325 not found
Michael Schulte zur Sur
Honored Contributor

Re: Problems with ls

Hi,

just do a ls -lb without files as parameter

Michael
Jeff Picton
Regular Advisor

Re: Problems with ls

Hi

Yes as I say I can do an ls -lb in the directory to get a list of files but cannot do an ls -lb on an individual file.

Jeff
Darren Prior
Honored Contributor

Re: Problems with ls

Hi Jeff,

What happens when you use ls -lb on the dir? does it show your SNNLwhatever filename with any extra characters?

Does ls -lb *SNNL54020700_20040202_072325* work?

regards,

Darren.
Calm down. It's only ones and zeros...
T G Manikandan
Honored Contributor

Re: Problems with ls

$which ls
Jeff Picton
Regular Advisor

Re: Problems with ls

Hi Darren

As you see the reply to your question is yes - as below :-

ls -lb *SNNL54020700_20040202_072325*
-rw-r--r-- 1 root sys 115 Feb 2 07:23 SNNL54020700_20040202_072325

Jeff
Darren Prior
Honored Contributor

Re: Problems with ls

That's good news - it suggests there is any extra character (or characters) at the start and/or end of the filename. Repeat the test but leave off one of the asterisks to determine which end of the filename has the problem.

regards,

Darren.
Calm down. It's only ones and zeros...
John Strang
Regular Advisor

Re: Problems with ls

Hi Jeff,

It sounds to me as if your files have some hidden chartacters included in the filenames.

Try doing something like
ls -l S* to see if the files are listed; then
ls -l SN*
ls -l SNN*
etc etc to try to establish where the hidden characters are.

Hope this helps you in some way,

John
If you never make a mistake you'll never make anything.
Hoefnix
Honored Contributor
Solution

Re: Problems with ls

Try running next ls command to see if something is behind the name of the file (like a space)
ls | awk -Feol '{ printf "|%s|\n",$1 }'
output will be like:
|scripts|
|t|
|tmp |

The tmp file has space behind the filename.
Hopes this helps you to figure out what the problem is.

Regards,
Peter
Jeff Picton
Regular Advisor

Re: Problems with ls

Hi

I get the following :-

root@telesto[dublin_out1] ls | awk -Feol '{ printf "|%s|\n",$1 }' | more
|SIGR21010300_20040201_031111 |
|SIGR21010300_20040201_031139 |
|SIGR21010300_20040201_034926 |
|SIGR21010900_20040201_091011 |
|SIGR21010900_20040201_091100 |
|SIGR21010900_20040201_093457 |
|SIGR21011500_20040201_151004 |
|SIGR21011500_20040201_151129 |
|SIGR21011500_20040201_152144 |
|SIGR21012100_20040201_211001 |
|SIGR21012100_20040201_211138 |
|SIGR21012100_20040201_211836 |
|SIGR21012100_20040201_212920 |
|SIGR21020300_20040202_031010 |
|SIGR21020300_20040202_033906 |
|SIGR21020900_20040202_091051 |
Michael Schulte zur Sur
Honored Contributor

Re: Problems with ls

You can see any extra character with

ls *SNNL54020700_20040202_072325* | od -x

Michael
Hoefnix
Honored Contributor

Re: Problems with ls

Jeff,

It looks like you have 1 or multiple spaces(forum removes the multiples) behind each filename.

use the * behind the filename in your cat command to view the file (or reuse the awk from the ls)

Regards,

Peter
Jeff Picton
Regular Advisor

Re: Problems with ls

Hi

Thanks for your replies.

We have discovered multiple white spaces after the file name.

Jeff
Clay Jordan
Advisor

Re: Problems with ls

This is late for the party but

To see a file:
ls | cat -vet (shows non-printing characters, tabs and form-feeds visibly, with a $ as the end of line marker.)

To work with a file:

ls -i ( to get the inum ) and then
find -inum xxx -exec somecommand {} \;