#1 28 Nov 2008 02:34

Temonio
Member
Registered: 28 Nov 2008
Posts: 2

count the number of files found with find

Hello, I am reading and reading tutorials but i cannot find an answer to my problen:

im trying to count the number of files found with FIND, for example if i write the next code line

find . -name 'salida_0*' 

and i find 3 files named:
salida_00001_20081120121017
salida_00002_20081120121019
salida_00003_20081120121021

how can I give to a variable the number of files found with the name "salida_0*" in this case, give to a variable the number 3 ?

THanks a lot community and sorry, my english is quite poor.

Offline

#2 28 Nov 2008 13:21

Simon Sheppard
Super Administrator
Registered: 27 Aug 2005
Posts: 998
Website

Re: count the number of files found with find

$ result=$(find . -name 'salida_0*'|xargs -0 | wc -l)

$ echo $result

Online

#3 02 Dec 2008 20:48

Temonio
Member
Registered: 28 Nov 2008
Posts: 2

Re: count the number of files found with find

Wow man, thanks a lot.

Offline

Board footer

Powered by FluxBB