Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9247579
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T09:45:52+00:00 2026-06-18T09:45:52+00:00

I found this neat little script on the Ubuntu website. The script verifies contents

  • 0

I found this neat little script on the Ubuntu website. The script verifies
contents of CD by comparing it to an MD5 sum of an iso(9660) file. I don’t
understand why the script parses the string after the md5 sum is computed.

CSUM1=$(CHECKSUM "$1" | grep -om1 '^[0-9a-f]*')

How can I verify the the cmdline argument passed to the script is a real md5 hash (case insensitive and hex(0-9/a-f)). There’re several snippets online showing how to verify md5 hashes. I want to verify and grep the MD5 hash if an .md5 file is passed as an argument or verify the hash if its not. I got the script to compute and compare…

# Compares the checksums of an iso9660 image and a burned disk.
# This script is released into the public domain by it's author.
if [ -n "$BASH" ]
then
  shopt -s expand_aliases
fi

if [ -n "$CHECKSUM" ]
then
  alias CHECKSUM="$CHECKSUM"
elif which md5deep &> /dev/null
then
  alias CHECKSUM='md5deep -e'
else
  alias CHECKSUM='md5sum'
fi

if [ -n "$2" ]
then
  DISKDEVICE="$2"
else
  DISKDEVICE='/dev/cdrom'
fi

CSUM1=$(CHECKSUM "$1" | grep -om1 '^[0-9a-f]*')
# extract cmdline arg
echo 'checksum for input image:' $CSUM1
SIZE=$(stat -c '%s' "$1")
BLOCKS=$(expr $SIZE / 2048)
CSUM2=$(dd if="$DISKDEVICE" bs=2048 count=$BLOCKS 2>/dev/null | CHECKSUM | grep -om1 '^[0-9a-f]*')
echo 'checksum for output disk:' $CSUM2

if [ "$CSUM1" = "$CSUM2" ]
then
  echo 'verification successful!'
else
  echo 'verification failed!'
fi
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T09:45:53+00:00Added an answer on June 18, 2026 at 9:45 am

    I don’t understand why the script parses the string after the md5 sum is
    computed.
    CSUM1=$(CHECKSUM "$1" | grep -om1 '^[0-9a-f]*')

    It has to parse it because md5sum, et al don’t just put out the hash

    $ md5sum lupu-528.005.iso
    8ad170c46b523436776398fa5ce39fa4 *lupu-528.005.iso
    

    How can I verify the the cmdline argument passed to the script is a real md5
    hash

    With that script the intention is to pass a file, not a hash.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I found a neat Ruby script to sum all purchases done on Amazon.de (no
found this little code snippet that seems to do what i want, but im
In this blog I found a pretty neat example on how to create a
In the question below, I found this neat trick for calling QueueUserWorkItem in a
I found this neat tip on how to equally space divs within a container:
I found this neat command to merge multiple PDF into one, using Ghostscript: gs
Howdy, I love this neat thing found on css-tricks: a:active { position: relative; top:
Found this while reading the Neo4j manual, specifically here , I found the sentence:
Found This: tyty stack, Social Icons not working with Infinite Scrolling on Wordpress I'm
Found this Multimap containing pairs? , but it is not much help How would

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.