Monday, 9 July 2012

Counting the files with different extensions in a directory (UNIX)

                For listing the files in UNIX we have a command called ls. It can also list multiple extension files at the same time. In a project I had to write a script for counting files with particular extensions alone i.e. XSL, RTF and XML.I wrote the code for counting the files. My manager suggested me to filter the files before counting to improve the process. I felt it was an amazing idea and it will come out of experienceJ.
For  f in `ls *.xml *.xsl *.rtf`
do
count_XSL=$(find  /tmp/files –type f –name “*.XSL” | wc -1)
done

No comments:

Post a Comment