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

file count in directory and sub-directories

Status
Not open for further replies.

grapes12

Technical User
Mar 2, 2010
124
0
0
ZA
I have two commands with different counts on the same directory.
directory /u1/oracle
Code:
find . -name '*' | wc -l
   69355
Code:
find . -type f -print | wc -l
   64008

I am assuming the first command includes hiden files and the second does not. Am I correct in my assumption or not.
How would I know what is the true count on the directory?
 
Hi

Compare the lists generated by those two commands to see what differs :
Code:
diff [teal]<([/teal] find [teal].[/teal] -name [green][i]'*'[/i][/green] [teal])[/teal] [teal]<([/teal] find [teal].[/teal] -type f -print [teal])[/teal]
( You will need a shell supporting process substitution for the above command, for example Bash or Zsh. If none available, use temporary files instead. )

For example :
Code:
[blue]master #[/blue] touch .one two; mkdir three

[blue]master #[/blue] ls -l 
total 0
drwxr-xr-x 2 master master 48 May 27 11:11 three/
-rw-r--r-- 1 master master  0 May 27 11:11 two

[blue]master #[/blue] find . -name '*'
.
./two
./.one
./three

[blue]master #[/blue] find . -type f -print
./two
./.one

[blue]master #[/blue] diff <( find . -name '*' ) <( find . -type f -print )
1d0
< .
4d2
< ./three

As you can see, the hidden file is included in both lists, but the directories not.


Feherke.
feherke.github.io
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top