Anil Kumar Nelakuditi Anil Kumar Nelakuditi - 4 months ago 19
Bash Question

How read paths in text file and get the file count under that paths

I have a text file which contains multiple paths like below

$ cat directory.txt

I need to change directory to each path in text file and need to get count of files under that paths.Below is the code i used, But it is not working.

cat /aaaa/bbbbb/directory.txt

while read $i ;do
cd $i
ls |wc -l
done < /aaaa/bbbbb/count.txt


 for i in `cat /aaaa/bbbbb/directory.txt`
   cd $i
   ls | wc -l >>/aaaa/bbbbb/count.txt

cat the filename in special single quote. that is in tilde sign. It will be solved.