regex - Grep inside of multiple directories and zipped files -


i have lot of zipped files, each contains json files , txt files in directory. want find total number of json files in zipped files in directory.

to drill down, have lot of such directories.
how find out total count of json files within zipped files within directories?

through find command, can iterate through each directory have , match against named pattern such *.zip.

when go through list find returns (a for loop here) need list files in each archive (you won't have extract files, good) , while you're listing files can simple grep find .json pattern , pipe output wc -l give "line count" - in case represent number of .json files.

throughout each iteration, you'd take count , add "total" count can later output.

an expanded sample of be:

total=0; file in `find . -name '*.zip'`;     count=`unzip -l $file | grep '.json' | wc -l`;     total=`expr $total + $count`; done; echo "total json files: $total"; 

this sample assumes you're using zip archive files. if you're using tar you'll need use file-listing parameters (tar -t).


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -