We want to find all the .jar files with their chksum.

find . -name "*.jar"


expected output

find . -name "*.jar"

ant-1.8.0.jar  325235345 4564
ant-launcher-1.8.0.jar 3523535 5453

Is it possible to add to find the command with sum, and print all .jar files with the relevant sum?


You can use the exec action of find to do this:

find . -name "*.jar" -exec cksum {} \+

The exec action runs the cksum command on each result of find. The + operator specifies that multiple results from find are passed to a single execution of cksum.

Do note that the order of columns is slightly different from your question. This is governed by the output of the cksum command, which outputs the information as [checksum] [byte count] [filename].

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.