Glam Prestige Journal

Bright entertainment trends with youth appeal.

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 done

the 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.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy