-1

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

find . -name "*.jar"

./lib/ant-1.8.0.jar
./lib/ant-launcher-1.8.0.jar
./lib/backport-util-concurrent-3.1.jar
./lib/classworlds-1.1-alpha-2.jar
./lib/commons-codec-1.6.jar
./lib/commons-io-2.2.jar
./lib/commons-logging-1.1.1.jar
./lib/jline-0.9.94.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?

3

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.