print as well as count the files found by find command


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting print as well as count the files found by find command
# 1  
Old 02-05-2009
print as well as count the files found by find command

I want the output of the find command to be printed and also the total files found by it. Can someone help in this.

Obviously $ find . -type f | wc -l will not output the files found but only the count. I want both. There can be millions and trillions of files so dont want the output of find to be written in a file or a variable first.
# 2  
Old 02-05-2009
Something like this?

Code:
find . -type f | awk '{n++;print}END{print n}'

Regards
# 3  
Old 02-05-2009
Thumbs up...
# 4  
Old 02-05-2009
Code:
find . -type f | awk 'END{ print NR }'

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Assistance with my Find command to identify last part of a file name and report the name found

Hello Forum, We have two bootstraps of Chef in our environment which are identified by colour: /var/chef/cache/cookbooks/bootstrap_cookbooks_version_green and /var/chef/cache/cookbooks/bootstrap_cookbooks_version_red I'm attempting to identify which version is installed based on the name... (11 Replies)
Discussion started by: greavette
11 Replies

2. Shell Programming and Scripting

Purge X old days files and Print count

Hello All, I am trying to purge X old days of files from directory & Sub directories ./2016-01-13/1500/abc.txt ./2016-01-14/1605/caf.txt ./2016-01-14/1605/caf2.txt ./2016-01-14/1606/eaf.txt ..... ./2017-08-1/1701/ Should also remove directories and sub directories too Expected... (7 Replies)
Discussion started by: krux_rap
7 Replies

3. Shell Programming and Scripting

Copy/print all lines between pattern is found in .log files

Hi, I have a folder with multiple (< 33) .log files. And I have to copy the lines between two patterns from all the .log files to a new file. (script file with a loop?) Thanks in advance. 1.log ... .. xx1> begin ... .. .. >>> Total: 2 Alarms .. .. (17 Replies)
Discussion started by: AK47
17 Replies

4. Shell Programming and Scripting

File count for symlink using find command

Hi Guys, The script which I am using works really good for finding the file count for files that are not symlink. I know I can use find command like: find . -type l | wc -l This way I can get filecount of the symlink but is there a one liner to use -type l and -type f option ? That is... (4 Replies)
Discussion started by: dixits
4 Replies

5. Shell Programming and Scripting

find with xargs to rm found files

I believe what is happening is rm is executing in the script on every directory and on failure of the first it stops although returns status 0. find $HOME -name /directory/filename | xargs -l rm This is the code I use but file remains. I am using sun solaris system which has way limited... (4 Replies)
Discussion started by: Ebodee
4 Replies

6. Shell Programming and Scripting

I need to find one command from multiple files and need to print that file which contains neede com

Hi all i need your help .. I am having a multiple file in directory and i have find out the Rcopy word from these files and need to print those files which contains the Rcopy word Thanks and regards Vijay sahu (2 Replies)
Discussion started by: vijays3
2 Replies

7. UNIX for Dummies Questions & Answers

print: command not found

Hi I have print Apple >> /tmp/temp7.xls as part of my shell script. But when I execute I have the following error. Please help. RT.sh: line 801: print: command not found (5 Replies)
Discussion started by: pk_eee
5 Replies

8. Shell Programming and Scripting

find command in while loop - how to get control when no files found?

I have the following statement in script: find ${LANDING_FILE_DIR}${BTIME_FILENAME_PATTERN2} -print | while read file; do ... done When there are no files located by the find comand it returns: "find: bad status-- /home/rnitcher/test/....." to the command line How do I get control in... (3 Replies)
Discussion started by: mavsman
3 Replies

9. Shell Programming and Scripting

Help with find command and list in a long format each found file

The purpose of those comands are to find the newest file in a directory acvrdind to system date, and it has to be recursively found in each directory. The problem is that i want to list in a long format every found file, but the commands i use produce unexpected results ,so the output lists in a... (5 Replies)
Discussion started by: alexcol
5 Replies

10. Shell Programming and Scripting

awk command to find the count of files ina directory

hi Gurus, can anyone provide a awk command to get teh count of number of file sin a specific directory. appreciate any kind of information.. thanks (11 Replies)
Discussion started by: sish78
11 Replies
Login or Register to Ask a Question