0

How would I script something so that it gives me a list of crcs along with the paths, like an sfv file? I could code this in python but there is probably a simpler way in shell.

So far I have:

find . -type f -exec crc32 {} \; > chksum.txt

But this doesn't include the paths

An example output would be:

file_one.zip   c45ad668
file_two.zip   7903b8e6
file_three.zip e99a65fb
  • Is this the crc32 utility distributed as part of the Archive::Zip Perl module? – Kusalananda Mar 1 at 8:52
0

You can run a sub-shell inside the -exec option that can go through the individual file names and do the action of your choice

find . -type f -exec sh -c '
    for file; do 
        echo "$file" "$(crc32 "$file")"
    done' sh {} +

The for loop inside gets the list of names from find as one long list of positional arguments, i.e. for file; do is a short hand representation for for file in "$@"; do where the list $@ is populated by find command.

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.