1833059 Members
2928 Online
110049 Solutions
New Discussion

list file difference

 
ust3
Regular Advisor

list file difference

I have a directory eg. /tmp/ , there is many .tmp , I try to use "ls *.tmp" , it can show all .tmp files normally , it works fine. but if I use "ls *tmp" , then it not only show the files in /tmp , but also show all files in the SUBDIRECTORY of /tmp , what is difference of these command ? or there is problem in my system ? thx
5 REPLIES 5
A. Clay Stephenson
Acclaimed Contributor

Re: list file difference

Why would you expect *.tmp and *tmp* to list the same things? The first case would also list (and expand) any directories that were named xxxxx.tmp. You simply don't have any directory names that match the pattern.

The solution is to add the -d option. ls -d *tmp* will list the directory name but not the contents.

A man ls would have explained this.
If it ain't broke, I can fix that.
Dennis Handly
Acclaimed Contributor

Re: list file difference

Can you show a few examples?
*.tmp This will show all files AND directories with *.tmp. If no directories, you just see the files.

*tmp will show all files AND directories with *tmp. If it finds directories, then subdirectory contents are listed too. If you want to stop that, use: ls -d *tmp

If you want to go all the way down (to the bottom turtle :-), add -R.
Kapil Jha
Honored Contributor

Re: list file difference

Simple
*.tmp means anything ending with .tmp
and
*tmp means anything ending with tmp
generally we have only files with name .tmp and not dorectory.
And that is I suppose is the question to your answer.
BR,
Kapil
I am in this small bowl, I wane see the real world......
ust3
Regular Advisor

Re: list file difference

Thx all replies,

I understand it.
Dennis Handly
Acclaimed Contributor

Re: list file difference

>Thx all replies,

Our answers weren't worth any points? :-)
You can reopen this with:
http://forums12.itrc.hp.com/service/forums/helptips.do?#41

You should at least indicate your problem was solved, with a bunny.