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!

Deleting files??? files that seem to exist and not exist

Status
Not open for further replies.

Chrissirhc

Programmer
May 20, 2000
926
GB
Hi,

I do ls -lt | grep PDF in a directory and I get a list of PDFs that exist in the directory.

Now I do ls *.PDF and I get *.PDF: No such file or directory

If I do rm *.PDF I get *.PDF: No such file or directory

If I try to delete one of the files I get No such file or directory.

How is this possible?

Thanks,

Chris
 
Chrissirhc
Can you please list the output of the `ls -lt | grep PDF` command ? Also, which shell are you using ? If you are using the ksh shell, then your noglob option must be turned on.
Try using `set +o noglob` and then re-execute your commands above.

Hope this helps ya.
 
Do

rm -i *PDF*

It possible that the the filename has an unseen char usually a control char.

Use

ls -alb to show all files including ones with nonprintable chars.

Take a look at the man page for ls



--
| Mike Nixon
| Unix Admin
|
----------------------------
 
As an addendum to the above post,

The command 'set -o noglob' turns off globbing (file name generation).

The command 'set +o noglob' turns on globbing.

For more details, refer to 'man set'

Hope this helps ya.
 
Ok looks like I needed *PDF*. This is strange. Where abouts in the filename would this character have been?

Because ls *.PDF returns nothing
but ls *PDF* returns something

 
Perhaps the filenames have a trailing space

*.PDF matches PDF right at the end of the filename
*PDF* matches PDF anywhere in the filename

As mrn suggests, use whatever ls options you have to reveal non-printing / whitespace characters.
 
ls -lb doesn't highlight any trailing spaces because they're printable.
Use ls|od -hc instead.
 
Hi chris

Since your login shell is ksh and globbing is turned off
you are getting this problem...
Also you will have the same problem if your login shell is bourne shell(sh)

METHOD(1):
ALL YOU HAVE TO DO IS:run this command : set +o noglob
That's it!
Now try ls *.PDF (you will get all pdf files)


METHOD(2):

Alternately u can change the your default login shell(ksh)
to either csh ...temporarily and you won't get that problem...

to achieve this(changing to csh)
$export SHELL=csh
and check with the command :echo $SHELL
It outputs : csh
Then it is set...you can get the commands work for you
ls *.PDF and what ever rm *.PDF

sushveer
IBM certified specialist-p-series AIX5L System Administration
AIX/SOLARIS/WEBSPHERE-MQ/TIVOLI Administrator
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top