I have a bunch of files, and need to examine all which are non-empty. I can find these files e.g. by running
find *e* -maxdepth 1 -size +0 -print
But if I add | less
to the above, I only get to see the list of files, not the files themselves.
If I manually give this filelist as an argument to less (less file1.e file2.e file3.e
etc.) I get what I want, but this kind of cumbersome. Is there any way I can pipe the output of find to less directly?
To run less
on each file in turn:
find *e* -type f -maxdepth 1 -size +0 -exec less {} \;
or:
find *e* -type f -maxdepth 1 -size +0 | xargs less
to run less
on the entire list (assuming the number of files is not huge - xargs limits max no of arguments to 5000 typically).
Note that addition of -type f
so that you don't return directories from find
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With