I have this command:
find . -name "*.php" -exec wc -L '{}' \; And I believe it gives me the count of the longest line for each file. But I'm looking for a way to only print out the count and file location if the length is greater the 500.
Has anyone done this before?
1 Answer
here is a crude script which does what you want
find . -name "*.php" -exec wc -L '{}' \; | while read maxlinelength filename do if [ 500 -lt $maxlinelength ] then echo $maxlinelength $filename fi donethe output of the find-wc combination is piped to a while read loop which puts each line of maxlinelength and filename in the variables $maxlinelength and $filename. the if then checks whether 500 is less than $maxlinelength and if it is prints the values.