Search code examples
bashlswc

How to list number of lines inside each file listed by the ls command?


I am using the bash ls command as follows:

ls -S -l *usc*.vhd

This lists all the files that have the letters usc in its name and ends with .vhd extension. Now, I also need the output to print how many lines there are in each file. Is this possible in bash? I will need to use wc command of bash in some way but don't know how.


Solution

  • Use find with exec param instead of ls command:

    find . -type f -name "*usc*.vhd" -exec wc -l {} \;