I am using this code to read and print "file name" and "lines numbers", but the code can't read over 1 directory then stop without error msg?!
#!/bin/bash
find . -type d > mydirectory.txt
MyDir=mydirectory.txt
while read -r line; do
FileDir=$line/*.txt
for file in ${FileDir}
do
awk 'END{q="\047"; print "filename",", nlines"; print q FILENAME q "," q NR q}' "$file"
done > list.txt
done < mydirectory.txt
first line:
find . -type d > mydirectory.txt
get all directory and sub directory then save it in "mydirectory.txt".
then read every line in "mydirectory.txt" her:
while read -r line; do
FileDir=$line/*.txt
please what is the wrong, the code search in the first directory only! Regards