Skip to main content
deleted 8 characters in body
Source Link
mikeserv
  • 59.4k
  • 10
  • 122
  • 242

The shell has a built-in variable expansion field separator. So if you have a string and your delimiter is solid you can do:

var=32768,'dff0207a-591f-4435-9f8b-7b9b3e6ba2c1','d1f77359b3f7236806489ba3108c771f','NUMBER','US_EN','LATIN','GREEK','GERMAN'
(   IFS=,; set -f
    for field in $var
    do  printf '\n%s\n\t' "$field - md5:" >&2
        printf %s "$field" |
        md5sum
    done |
    cut -d\  -f1
)

32768 - md5:
        f43764367fa4b73ba947fae71b0223a4

dff0207a-591f-4435-9f8b-7b9b3e6ba2c1 - md5:
        0983e6c45209f390461c1b1df9320674

d1f77359b3f7236806489ba3108c771f - md5:
        07d82ab57ba81f991ab996bd7c5a0441

NUMBER - md5:
        34f55eca38e0605a84f169ff61a2a396

US_EN - md5:
        c9d3e580b7b102e864d9aea8703486ab

LATIN - md5:
        0e869135050d24ea6e7a30fc6edbac6c

GREEK - md5:
        d4cacc28e56302bcec9d7af4bba8c9a7

GERMAN - md5:
        ed73cca110623766d7a2457331a4f373

That should give you a newline separated list of md5s - as it did me.

IFS=, is used to specify that when any variable type shell expansion is performed the shell should split it out on the , character rather than <space><newline><tab> - which is the default. set -f is used to specify that if the shell should encounter any file globs within an unquoted expansion it should not expand them - so echo * would print only * regardless of the contents of the current directory.

For every comma separated field in $var the shell does printf "$field" | md5sum - so once per field without without separator strings as I take the question to mean. And last cut trims the few spaces and the - at the end of each output line as it receives them. Most of the output is actually to stderr - cut only ever sees the md5sums.

The shell has a built-in variable expansion field separator. So if you have a string and your delimiter is solid you can do:

var=32768,'dff0207a-591f-4435-9f8b-7b9b3e6ba2c1','d1f77359b3f7236806489ba3108c771f','NUMBER','US_EN','LATIN','GREEK','GERMAN'
(   IFS=,; set -f
    for field in $var
    do  printf '\n%s\n\t' "$field - md5:" >&2
        printf %s "$field" |
        md5sum
    done |
    cut -d\  -f1
)

32768 - md5:
        f43764367fa4b73ba947fae71b0223a4

dff0207a-591f-4435-9f8b-7b9b3e6ba2c1 - md5:
        0983e6c45209f390461c1b1df9320674

d1f77359b3f7236806489ba3108c771f - md5:
        07d82ab57ba81f991ab996bd7c5a0441

NUMBER - md5:
        34f55eca38e0605a84f169ff61a2a396

US_EN - md5:
        c9d3e580b7b102e864d9aea8703486ab

LATIN - md5:
        0e869135050d24ea6e7a30fc6edbac6c

GREEK - md5:
        d4cacc28e56302bcec9d7af4bba8c9a7

GERMAN - md5:
        ed73cca110623766d7a2457331a4f373

That should give you a newline separated list of md5s - as it did me.

IFS=, is used to specify that when any variable type shell expansion is performed the shell should split it out on the , character rather than <space><newline><tab> - which is the default. set -f is used to specify that if the shell should encounter any file globs within an unquoted expansion it should not expand them - so echo * would print only * regardless of the contents of the current directory.

For every comma separated field in $var the shell does printf "$field" | md5sum - so once per field without without separator strings as I take the question to mean. And last cut trims the few spaces and the - at the end of each output line as it receives them. Most of the output is actually to stderr - cut only ever sees the md5sums.

The shell has a built-in variable expansion field separator. So if you have a string and your delimiter is solid you can do:

var=32768,'dff0207a-591f-4435-9f8b-7b9b3e6ba2c1','d1f77359b3f7236806489ba3108c771f','NUMBER','US_EN','LATIN','GREEK','GERMAN'
(   IFS=,; set -f
    for field in $var
    do  printf '\n%s\n\t' "$field - md5:" >&2
        printf %s "$field" |
        md5sum
    done |
    cut -d\  -f1
)

32768 - md5:
        f43764367fa4b73ba947fae71b0223a4

dff0207a-591f-4435-9f8b-7b9b3e6ba2c1 - md5:
        0983e6c45209f390461c1b1df9320674

d1f77359b3f7236806489ba3108c771f - md5:
        07d82ab57ba81f991ab996bd7c5a0441

NUMBER - md5:
        34f55eca38e0605a84f169ff61a2a396

US_EN - md5:
        c9d3e580b7b102e864d9aea8703486ab

LATIN - md5:
        0e869135050d24ea6e7a30fc6edbac6c

GREEK - md5:
        d4cacc28e56302bcec9d7af4bba8c9a7

GERMAN - md5:
        ed73cca110623766d7a2457331a4f373

That should give you a newline separated list of md5s - as it did me.

IFS=, is used to specify that when any variable type shell expansion is performed the shell should split it out on the , character rather than <space><newline><tab> - which is the default. set -f is used to specify that if the shell should encounter any file globs within an unquoted expansion it should not expand them - so echo * would print only * regardless of the contents of the current directory.

For every comma separated field in $var the shell does printf "$field" | md5sum - so once per field without separator strings as I take the question to mean. And last cut trims the few spaces and the - at the end of each output line as it receives them. Most of the output is actually to stderr - cut only ever sees the md5sums.

added 1305 characters in body
Source Link
mikeserv
  • 59.4k
  • 10
  • 122
  • 242

The shell has a built-in field variable expansion field separator. So if you have a string and your delimiter is solid you can do:

var=32768,'dff0207a-591f-4435-9f8b-7b9b3e6ba2c1','d1f77359b3f7236806489ba3108c771f','NUMBER','US_EN','LATIN','GREEK','GERMAN'
(   IFS=,; set -f; IFS=,f
    for field in $var
    do  printf '\n%s\n\t' "$field - md5:" >&2
        printf %s "$field" |
        md5sum
    done | 
 sed 's/ .*//' cut -d\  -f1
)

###OUTPUT


32768 - md5:
        f43764367fa4b73ba947fae71b0223a4 

dff0207a-591f-4435-9f8b-7b9b3e6ba2c1 - md5:
        0983e6c45209f390461c1b1df9320674 

d1f77359b3f7236806489ba3108c771f - md5:
        07d82ab57ba81f991ab996bd7c5a0441

NUMBER - md5:
        34f55eca38e0605a84f169ff61a2a396 

US_EN - md5:
        c9d3e580b7b102e864d9aea8703486ab 

LATIN - md5:
        0e869135050d24ea6e7a30fc6edbac6c

GREEK - md5:
        d4cacc28e56302bcec9d7af4bba8c9a7 

GERMAN - md5:
        ed73cca110623766d7a2457331a4f373

That should give you a newline separated list of md5s - as it did me.

IFS=, is used to specify that when any variable type shell expansion is performed the shell should split it out on the , character rather than <space><newline><tab> - which is the default. set -f is used to specify that if the shell should encounter any file globs within an unquoted expansion it should not expand them - so echo * would print only * regardless of the contents of the current directory.

For every comma separated field in $var the shell does printf "$field" | md5sum - so once per field without without separator strings as I take the question to mean. And last cut trims the few spaces and the - at the end of each output line as it receives them. Most of the output is actually to stderr - cut only ever sees the md5sums.

The shell has a built-in field variable expansion field separator. So if you have a string and your delimiter is solid you can do:

var=32768,'dff0207a-591f-4435-9f8b-7b9b3e6ba2c1','d1f77359b3f7236806489ba3108c771f','NUMBER','US_EN','LATIN','GREEK','GERMAN'
(   set -f; IFS=,
    for field in $var
    do  printf %s "$field" | md5sum
    done | sed 's/ .*//'
)

###OUTPUT

f43764367fa4b73ba947fae71b0223a4
0983e6c45209f390461c1b1df9320674
07d82ab57ba81f991ab996bd7c5a0441
34f55eca38e0605a84f169ff61a2a396
c9d3e580b7b102e864d9aea8703486ab
0e869135050d24ea6e7a30fc6edbac6c
d4cacc28e56302bcec9d7af4bba8c9a7
ed73cca110623766d7a2457331a4f373

That should give you a newline separated list of md5s - as it did me.

The shell has a built-in variable expansion field separator. So if you have a string and your delimiter is solid you can do:

var=32768,'dff0207a-591f-4435-9f8b-7b9b3e6ba2c1','d1f77359b3f7236806489ba3108c771f','NUMBER','US_EN','LATIN','GREEK','GERMAN'
(   IFS=,; set -f
    for field in $var
    do  printf '\n%s\n\t' "$field - md5:" >&2
        printf %s "$field" |
        md5sum
    done | 
    cut -d\  -f1
)

32768 - md5:
        f43764367fa4b73ba947fae71b0223a4 

dff0207a-591f-4435-9f8b-7b9b3e6ba2c1 - md5:
        0983e6c45209f390461c1b1df9320674 

d1f77359b3f7236806489ba3108c771f - md5:
        07d82ab57ba81f991ab996bd7c5a0441

NUMBER - md5:
        34f55eca38e0605a84f169ff61a2a396 

US_EN - md5:
        c9d3e580b7b102e864d9aea8703486ab 

LATIN - md5:
        0e869135050d24ea6e7a30fc6edbac6c

GREEK - md5:
        d4cacc28e56302bcec9d7af4bba8c9a7 

GERMAN - md5:
        ed73cca110623766d7a2457331a4f373

That should give you a newline separated list of md5s - as it did me.

IFS=, is used to specify that when any variable type shell expansion is performed the shell should split it out on the , character rather than <space><newline><tab> - which is the default. set -f is used to specify that if the shell should encounter any file globs within an unquoted expansion it should not expand them - so echo * would print only * regardless of the contents of the current directory.

For every comma separated field in $var the shell does printf "$field" | md5sum - so once per field without without separator strings as I take the question to mean. And last cut trims the few spaces and the - at the end of each output line as it receives them. Most of the output is actually to stderr - cut only ever sees the md5sums.

Source Link
mikeserv
  • 59.4k
  • 10
  • 122
  • 242

The shell has a built-in field variable expansion field separator. So if you have a string and your delimiter is solid you can do:

var=32768,'dff0207a-591f-4435-9f8b-7b9b3e6ba2c1','d1f77359b3f7236806489ba3108c771f','NUMBER','US_EN','LATIN','GREEK','GERMAN'
(   set -f; IFS=,
    for field in $var
    do  printf %s "$field" | md5sum
    done | sed 's/ .*//'
)

###OUTPUT

f43764367fa4b73ba947fae71b0223a4
0983e6c45209f390461c1b1df9320674
07d82ab57ba81f991ab996bd7c5a0441
34f55eca38e0605a84f169ff61a2a396
c9d3e580b7b102e864d9aea8703486ab
0e869135050d24ea6e7a30fc6edbac6c
d4cacc28e56302bcec9d7af4bba8c9a7
ed73cca110623766d7a2457331a4f373

That should give you a newline separated list of md5s - as it did me.