LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-03-2016, 08:57 AM   #1
andrew.comly
Member
 
Registered: Dec 2012
Distribution: Trisquel-Mini 7.0, Lubuntu 14.04, Debian lxde 8.0
Posts: 311
Blog Entries: 2

Rep: Reputation: 16
Question sha256sum -c: How to limit to just one ISO file?


I have this directory "lubuntu14.04", contents shown below:
Code:
$ ll
total 1406360
-rw-rw-r--. 1 a adm 727711744  5月 18  2015 lubuntu-14.04-desktop-amd64.iso
-rwxrwxrwx. 1 a adm 716177408 12月  1  2014 lubuntu-14.04-desktop-i386.iso*
-rw-rw-r--. 1 a a           0  8月 29 09:27 new.sign
-rw-rw-r--. 1 a a        2722  8月  5 04:40 SHA256SUMS
-rw-rw-r--. 1 a a         933  8月  5 04:40 SHA256SUMS.gpg
I would like to generate a sha256 checksum for the downloaded ISO file "lubuntu-14.04-desktop-i386.iso" and compare it to the official sha256 checksum listed in the downloaded "SHA256SUMS" file.

Attempt 1:
Code:
$ sha256sum -c SHA256SUMS 2>&1 | grep OK
lubuntu-14.04-desktop-amd64.iso: OK
lubuntu-14.04-desktop-i386.iso: OK
Unfortunately the command above checks the "*amd64.iso" file in addition, slowing down the whole process. So I check the sha256sum manual file, and all I can find is:
Quote:
-c, --check
read SHA256 sums from the FILEs and
check them
Actually the manual file for sha256sum is so short, that there probably isn't the functionality I am looking for.

In this next attempt I write the ISO's full name after the "SHA256SUMS" file:

Attempt 2:
Code:
lubuntu14.04$ sha256sum -c SHA256SUMS lubuntu-14.04-desktop-i386.iso 2>&1 | grep OK
lubuntu-14.04-desktop-amd64.iso: OK
lubuntu-14.04-desktop-i386.iso: OK
The command sha256sum still checks the unwanted "*amd64.iso" ISO file.

Is there a way to only check the *.i386.iso file when both ISO files are in the directory "lubuntu14.04"?
 
Old 09-03-2016, 09:26 AM   #2
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,776

Rep: Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212
Only way I know of is to use a filter to select the one line you want from the sums file:
Code:
fgrep lubuntu-14.04-desktop-i386.iso SHA256SUMS | sha256sum -c -
# or
sha256sum -c <(fgrep lubuntu-14.04-desktop-i386.iso SHA256SUMS)
 
1 members found this post helpful.
Old 09-03-2016, 01:06 PM   #3
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
https://help.ubuntu.com/community/HowToSHA256SUM
https://help.ubuntu.com/community/VerifyIsoHowto

may help.
 
1 members found this post helpful.
Old 09-04-2016, 05:51 AM   #4
andrew.comly
Member
 
Registered: Dec 2012
Distribution: Trisquel-Mini 7.0, Lubuntu 14.04, Debian lxde 8.0
Posts: 311

Original Poster
Blog Entries: 2

Rep: Reputation: 16
Thumbs up Thanks!

Quote:
Originally Posted by rknichols View Post
Only way I know of is to use a filter to select the one line you want from the sums file:
Code:
fgrep lubuntu-14.04-desktop-i386.iso SHA256SUMS | sha256sum -c -
Works perfectly! Thanks a lot!

Andrew
 
Old 09-04-2016, 06:11 AM   #5
andrew.comly
Member
 
Registered: Dec 2012
Distribution: Trisquel-Mini 7.0, Lubuntu 14.04, Debian lxde 8.0
Posts: 311

Original Poster
Blog Entries: 2

Rep: Reputation: 16
Question How does this work?

Quote:
Originally Posted by rknichols View Post
sha256sum -c <(fgrep lubuntu-14.04-desktop-i386.iso SHA256SUMS)[/code]
Both solutions work, but if the above command works, and additionally when I execute the fgrep/grep command individually:
Code:
$ fgrep lubuntu-14.04-desktop-i386.iso SHA256SUMS
bba48a1d21720725fcc8f0b8461ba25631c8e28e8ca1aff7c14a1e151290da49 *lubuntu-14.04-desktop-i386.iso
Why then when does the following command produce a different result(fail):
Code:
sha256sum -c bba48a1d21720725fcc8f0b8461ba25631c8e28e8ca1aff7c14a1e151290da49 *lubuntu-14.04-desktop-i386.iso

{fail}
sha__sum and gpg commands are quite peculiar.
 
Old 09-04-2016, 10:03 AM   #6
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,776

Rep: Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212
There is nothing peculiar about those commands. You are just misunderstanding the shell syntax.

When you write
Code:
sha256sum -c <(fgrep lubuntu-14.04-desktop-i386.iso SHA256SUMS)
the shell runs the fgrep command with its output directed to some high-numbered file descriptor and tells the sha256sum command to read from that pseudo-file:
Code:
sha256sum -c /dev/fd/63
That is not the same as building a command line that includes the output from fgrep. You are confusing the syntax "<(some_command)" with "$(some_command)". They are very different. The first passes the name of a file that can be opened. The second just substitutes text into the command line.
 
1 members found this post helpful.
  


Reply

Tags
checksum, iso



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
unable to run sha256sum from terminal, Bobrm2 Linux - General 2 08-16-2016 04:09 AM
[SOLVED] help incorporating sha256sum into C code ron7000 Programming 5 06-17-2015 09:01 AM
[SOLVED] Download Size Limit for Iso File? Gene Falck Linux - Newbie 66 06-22-2014 11:54 PM
[SOLVED] Perl SHA256SUM Clarification Sky.Crawler Programming 2 02-28-2011 08:33 PM
8 characters limit in iso file mahmoodn Linux - General 3 07-21-2010 03:17 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:17 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration