awk inside another awk's system
Clash Royale CLAN TAG#URR8PPP
I am given a file containing the md5 values for files within the same folder. The information is in the file md5checksums.txt
in the following format:
b0da7ead9d82a3494d7e0a7099871ef4 ./GCF_000959505.1_ASM95950v1_assembly_report.txt
7ff32cbb16daf46c87b3546ad576ff66 ./GCF_000959505.1_ASM95950v1_assembly_stats.txt
034081da3aa0708f06c2ec1129e4aca9 ./GCF_000959505.1_ASM95950v1_cds_from_genomic.fna.gz
I want to do md5 checks for all the files. I got this command:
awk 'system("md5 "$2)' md5checksums.txt
But this just gets the md5 values
MD5 (./GCF_000959505.1_ASM95950v1_assembly_report.txt) = b0da7ead9d82a3494d7e0a7099871ef4
MD5 (./GCF_000959505.1_ASM95950v1_assembly_stats.txt) = 7ff32cbb16daf46c87b3546ad576ff66
MD5 (./GCF_000959505.1_ASM95950v1_cds_from_genomic.fna.gz) = 3a30966523a36368ab432f666001f80a
I would like to extract the calculated md5 against the first column of md5checksums.txt
I thought I could do something like an awk inside an awk, but I can't get it to work:
awk 'system("md5 "$2" ' md5checksums.txt
awk hashsum
add a comment |
I am given a file containing the md5 values for files within the same folder. The information is in the file md5checksums.txt
in the following format:
b0da7ead9d82a3494d7e0a7099871ef4 ./GCF_000959505.1_ASM95950v1_assembly_report.txt
7ff32cbb16daf46c87b3546ad576ff66 ./GCF_000959505.1_ASM95950v1_assembly_stats.txt
034081da3aa0708f06c2ec1129e4aca9 ./GCF_000959505.1_ASM95950v1_cds_from_genomic.fna.gz
I want to do md5 checks for all the files. I got this command:
awk 'system("md5 "$2)' md5checksums.txt
But this just gets the md5 values
MD5 (./GCF_000959505.1_ASM95950v1_assembly_report.txt) = b0da7ead9d82a3494d7e0a7099871ef4
MD5 (./GCF_000959505.1_ASM95950v1_assembly_stats.txt) = 7ff32cbb16daf46c87b3546ad576ff66
MD5 (./GCF_000959505.1_ASM95950v1_cds_from_genomic.fna.gz) = 3a30966523a36368ab432f666001f80a
I would like to extract the calculated md5 against the first column of md5checksums.txt
I thought I could do something like an awk inside an awk, but I can't get it to work:
awk 'system("md5 "$2" ' md5checksums.txt
awk hashsum
3
BSD md5 vs GNU md5sum output. Givemd5
the-r
option to produce the same output format asmd5sum
.
– Mark Plotnick
Dec 19 '18 at 16:52
Great, but I still have to parse the results since they are given in 2 columns
– Julio Diaz
Dec 19 '18 at 16:56
do you want to check file againt their md5 sum ? Yes=>md5sum -r
Or see if same file comme with new name ?
– Archemar
Dec 19 '18 at 17:14
I suspect that this an escaping problem, you need to escape the$
to stop it being interpreted by the outer awk. I am sure there are better answers though.
– ctrl-alt-delor
Dec 19 '18 at 17:40
add a comment |
I am given a file containing the md5 values for files within the same folder. The information is in the file md5checksums.txt
in the following format:
b0da7ead9d82a3494d7e0a7099871ef4 ./GCF_000959505.1_ASM95950v1_assembly_report.txt
7ff32cbb16daf46c87b3546ad576ff66 ./GCF_000959505.1_ASM95950v1_assembly_stats.txt
034081da3aa0708f06c2ec1129e4aca9 ./GCF_000959505.1_ASM95950v1_cds_from_genomic.fna.gz
I want to do md5 checks for all the files. I got this command:
awk 'system("md5 "$2)' md5checksums.txt
But this just gets the md5 values
MD5 (./GCF_000959505.1_ASM95950v1_assembly_report.txt) = b0da7ead9d82a3494d7e0a7099871ef4
MD5 (./GCF_000959505.1_ASM95950v1_assembly_stats.txt) = 7ff32cbb16daf46c87b3546ad576ff66
MD5 (./GCF_000959505.1_ASM95950v1_cds_from_genomic.fna.gz) = 3a30966523a36368ab432f666001f80a
I would like to extract the calculated md5 against the first column of md5checksums.txt
I thought I could do something like an awk inside an awk, but I can't get it to work:
awk 'system("md5 "$2" ' md5checksums.txt
awk hashsum
I am given a file containing the md5 values for files within the same folder. The information is in the file md5checksums.txt
in the following format:
b0da7ead9d82a3494d7e0a7099871ef4 ./GCF_000959505.1_ASM95950v1_assembly_report.txt
7ff32cbb16daf46c87b3546ad576ff66 ./GCF_000959505.1_ASM95950v1_assembly_stats.txt
034081da3aa0708f06c2ec1129e4aca9 ./GCF_000959505.1_ASM95950v1_cds_from_genomic.fna.gz
I want to do md5 checks for all the files. I got this command:
awk 'system("md5 "$2)' md5checksums.txt
But this just gets the md5 values
MD5 (./GCF_000959505.1_ASM95950v1_assembly_report.txt) = b0da7ead9d82a3494d7e0a7099871ef4
MD5 (./GCF_000959505.1_ASM95950v1_assembly_stats.txt) = 7ff32cbb16daf46c87b3546ad576ff66
MD5 (./GCF_000959505.1_ASM95950v1_cds_from_genomic.fna.gz) = 3a30966523a36368ab432f666001f80a
I would like to extract the calculated md5 against the first column of md5checksums.txt
I thought I could do something like an awk inside an awk, but I can't get it to work:
awk 'system("md5 "$2" ' md5checksums.txt
awk hashsum
awk hashsum
edited Dec 19 '18 at 18:40
Rui F Ribeiro
39k1479129
39k1479129
asked Dec 19 '18 at 16:42
Julio Diaz
1113
1113
3
BSD md5 vs GNU md5sum output. Givemd5
the-r
option to produce the same output format asmd5sum
.
– Mark Plotnick
Dec 19 '18 at 16:52
Great, but I still have to parse the results since they are given in 2 columns
– Julio Diaz
Dec 19 '18 at 16:56
do you want to check file againt their md5 sum ? Yes=>md5sum -r
Or see if same file comme with new name ?
– Archemar
Dec 19 '18 at 17:14
I suspect that this an escaping problem, you need to escape the$
to stop it being interpreted by the outer awk. I am sure there are better answers though.
– ctrl-alt-delor
Dec 19 '18 at 17:40
add a comment |
3
BSD md5 vs GNU md5sum output. Givemd5
the-r
option to produce the same output format asmd5sum
.
– Mark Plotnick
Dec 19 '18 at 16:52
Great, but I still have to parse the results since they are given in 2 columns
– Julio Diaz
Dec 19 '18 at 16:56
do you want to check file againt their md5 sum ? Yes=>md5sum -r
Or see if same file comme with new name ?
– Archemar
Dec 19 '18 at 17:14
I suspect that this an escaping problem, you need to escape the$
to stop it being interpreted by the outer awk. I am sure there are better answers though.
– ctrl-alt-delor
Dec 19 '18 at 17:40
3
3
BSD md5 vs GNU md5sum output. Give
md5
the -r
option to produce the same output format as md5sum
.– Mark Plotnick
Dec 19 '18 at 16:52
BSD md5 vs GNU md5sum output. Give
md5
the -r
option to produce the same output format as md5sum
.– Mark Plotnick
Dec 19 '18 at 16:52
Great, but I still have to parse the results since they are given in 2 columns
– Julio Diaz
Dec 19 '18 at 16:56
Great, but I still have to parse the results since they are given in 2 columns
– Julio Diaz
Dec 19 '18 at 16:56
do you want to check file againt their md5 sum ? Yes=>
md5sum -r
Or see if same file comme with new name ?– Archemar
Dec 19 '18 at 17:14
do you want to check file againt their md5 sum ? Yes=>
md5sum -r
Or see if same file comme with new name ?– Archemar
Dec 19 '18 at 17:14
I suspect that this an escaping problem, you need to escape the
$
to stop it being interpreted by the outer awk. I am sure there are better answers though.– ctrl-alt-delor
Dec 19 '18 at 17:40
I suspect that this an escaping problem, you need to escape the
$
to stop it being interpreted by the outer awk. I am sure there are better answers though.– ctrl-alt-delor
Dec 19 '18 at 17:40
add a comment |
1 Answer
1
active
oldest
votes
I'm a bit confused as to why you involve awk
in this.
To verify the MD5 checksums in a file produced by GNU md5sum
, you do
md5sum -c file.txt
Or, on an OpenBSD or NetBSD system whose md5
utility supports -c filename
(not FreeBSD or macOS):
md5 -c file.txt
In your case, file.txt
would be your md5checksums.txt
file.
How would I check the resulting value to the one given in a file along the md5s of other files? I should have made it clear that I would like to check the md5 values for all the files in the folder.
– Julio Diaz
Dec 19 '18 at 16:50
@JulioDiaz I don't thing I understand that question. In my example,file.txt
is the file that contains the MD5 checksums and pathnames.md5sum -c file.txt
will calculate the MD5 checksums of the files listed and compare them to the corresponding pre-calculated checksums. You probably just need to usemd5checksums.txt
instead offile.txt
.
– Kusalananda
Dec 19 '18 at 16:55
I see. Is there a homologue to -c in md5?
– Julio Diaz
Dec 19 '18 at 16:59
@JulioDiaz You haven't yet said what type of Unix you are working with.
– Kusalananda
Dec 19 '18 at 17:07
Im working from OSX
– Julio Diaz
Dec 19 '18 at 17:10
|
show 2 more comments
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f489957%2fawk-inside-another-awks-system%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
I'm a bit confused as to why you involve awk
in this.
To verify the MD5 checksums in a file produced by GNU md5sum
, you do
md5sum -c file.txt
Or, on an OpenBSD or NetBSD system whose md5
utility supports -c filename
(not FreeBSD or macOS):
md5 -c file.txt
In your case, file.txt
would be your md5checksums.txt
file.
How would I check the resulting value to the one given in a file along the md5s of other files? I should have made it clear that I would like to check the md5 values for all the files in the folder.
– Julio Diaz
Dec 19 '18 at 16:50
@JulioDiaz I don't thing I understand that question. In my example,file.txt
is the file that contains the MD5 checksums and pathnames.md5sum -c file.txt
will calculate the MD5 checksums of the files listed and compare them to the corresponding pre-calculated checksums. You probably just need to usemd5checksums.txt
instead offile.txt
.
– Kusalananda
Dec 19 '18 at 16:55
I see. Is there a homologue to -c in md5?
– Julio Diaz
Dec 19 '18 at 16:59
@JulioDiaz You haven't yet said what type of Unix you are working with.
– Kusalananda
Dec 19 '18 at 17:07
Im working from OSX
– Julio Diaz
Dec 19 '18 at 17:10
|
show 2 more comments
I'm a bit confused as to why you involve awk
in this.
To verify the MD5 checksums in a file produced by GNU md5sum
, you do
md5sum -c file.txt
Or, on an OpenBSD or NetBSD system whose md5
utility supports -c filename
(not FreeBSD or macOS):
md5 -c file.txt
In your case, file.txt
would be your md5checksums.txt
file.
How would I check the resulting value to the one given in a file along the md5s of other files? I should have made it clear that I would like to check the md5 values for all the files in the folder.
– Julio Diaz
Dec 19 '18 at 16:50
@JulioDiaz I don't thing I understand that question. In my example,file.txt
is the file that contains the MD5 checksums and pathnames.md5sum -c file.txt
will calculate the MD5 checksums of the files listed and compare them to the corresponding pre-calculated checksums. You probably just need to usemd5checksums.txt
instead offile.txt
.
– Kusalananda
Dec 19 '18 at 16:55
I see. Is there a homologue to -c in md5?
– Julio Diaz
Dec 19 '18 at 16:59
@JulioDiaz You haven't yet said what type of Unix you are working with.
– Kusalananda
Dec 19 '18 at 17:07
Im working from OSX
– Julio Diaz
Dec 19 '18 at 17:10
|
show 2 more comments
I'm a bit confused as to why you involve awk
in this.
To verify the MD5 checksums in a file produced by GNU md5sum
, you do
md5sum -c file.txt
Or, on an OpenBSD or NetBSD system whose md5
utility supports -c filename
(not FreeBSD or macOS):
md5 -c file.txt
In your case, file.txt
would be your md5checksums.txt
file.
I'm a bit confused as to why you involve awk
in this.
To verify the MD5 checksums in a file produced by GNU md5sum
, you do
md5sum -c file.txt
Or, on an OpenBSD or NetBSD system whose md5
utility supports -c filename
(not FreeBSD or macOS):
md5 -c file.txt
In your case, file.txt
would be your md5checksums.txt
file.
edited Dec 19 '18 at 17:06
answered Dec 19 '18 at 16:48
Kusalananda
121k16229372
121k16229372
How would I check the resulting value to the one given in a file along the md5s of other files? I should have made it clear that I would like to check the md5 values for all the files in the folder.
– Julio Diaz
Dec 19 '18 at 16:50
@JulioDiaz I don't thing I understand that question. In my example,file.txt
is the file that contains the MD5 checksums and pathnames.md5sum -c file.txt
will calculate the MD5 checksums of the files listed and compare them to the corresponding pre-calculated checksums. You probably just need to usemd5checksums.txt
instead offile.txt
.
– Kusalananda
Dec 19 '18 at 16:55
I see. Is there a homologue to -c in md5?
– Julio Diaz
Dec 19 '18 at 16:59
@JulioDiaz You haven't yet said what type of Unix you are working with.
– Kusalananda
Dec 19 '18 at 17:07
Im working from OSX
– Julio Diaz
Dec 19 '18 at 17:10
|
show 2 more comments
How would I check the resulting value to the one given in a file along the md5s of other files? I should have made it clear that I would like to check the md5 values for all the files in the folder.
– Julio Diaz
Dec 19 '18 at 16:50
@JulioDiaz I don't thing I understand that question. In my example,file.txt
is the file that contains the MD5 checksums and pathnames.md5sum -c file.txt
will calculate the MD5 checksums of the files listed and compare them to the corresponding pre-calculated checksums. You probably just need to usemd5checksums.txt
instead offile.txt
.
– Kusalananda
Dec 19 '18 at 16:55
I see. Is there a homologue to -c in md5?
– Julio Diaz
Dec 19 '18 at 16:59
@JulioDiaz You haven't yet said what type of Unix you are working with.
– Kusalananda
Dec 19 '18 at 17:07
Im working from OSX
– Julio Diaz
Dec 19 '18 at 17:10
How would I check the resulting value to the one given in a file along the md5s of other files? I should have made it clear that I would like to check the md5 values for all the files in the folder.
– Julio Diaz
Dec 19 '18 at 16:50
How would I check the resulting value to the one given in a file along the md5s of other files? I should have made it clear that I would like to check the md5 values for all the files in the folder.
– Julio Diaz
Dec 19 '18 at 16:50
@JulioDiaz I don't thing I understand that question. In my example,
file.txt
is the file that contains the MD5 checksums and pathnames. md5sum -c file.txt
will calculate the MD5 checksums of the files listed and compare them to the corresponding pre-calculated checksums. You probably just need to use md5checksums.txt
instead of file.txt
.– Kusalananda
Dec 19 '18 at 16:55
@JulioDiaz I don't thing I understand that question. In my example,
file.txt
is the file that contains the MD5 checksums and pathnames. md5sum -c file.txt
will calculate the MD5 checksums of the files listed and compare them to the corresponding pre-calculated checksums. You probably just need to use md5checksums.txt
instead of file.txt
.– Kusalananda
Dec 19 '18 at 16:55
I see. Is there a homologue to -c in md5?
– Julio Diaz
Dec 19 '18 at 16:59
I see. Is there a homologue to -c in md5?
– Julio Diaz
Dec 19 '18 at 16:59
@JulioDiaz You haven't yet said what type of Unix you are working with.
– Kusalananda
Dec 19 '18 at 17:07
@JulioDiaz You haven't yet said what type of Unix you are working with.
– Kusalananda
Dec 19 '18 at 17:07
Im working from OSX
– Julio Diaz
Dec 19 '18 at 17:10
Im working from OSX
– Julio Diaz
Dec 19 '18 at 17:10
|
show 2 more comments
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f489957%2fawk-inside-another-awks-system%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
3
BSD md5 vs GNU md5sum output. Give
md5
the-r
option to produce the same output format asmd5sum
.– Mark Plotnick
Dec 19 '18 at 16:52
Great, but I still have to parse the results since they are given in 2 columns
– Julio Diaz
Dec 19 '18 at 16:56
do you want to check file againt their md5 sum ? Yes=>
md5sum -r
Or see if same file comme with new name ?– Archemar
Dec 19 '18 at 17:14
I suspect that this an escaping problem, you need to escape the
$
to stop it being interpreted by the outer awk. I am sure there are better answers though.– ctrl-alt-delor
Dec 19 '18 at 17:40