Create unique random numbers (UUIDs) in bash





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}







6















I want to create random unique numbers (UUIDs) as the following



node.id=ffffffff-ffff-ffff-ffff-ffffffffffff


First I tried this



$ rndnum=` echo $RANDOM"-"echo $RANDOM"-"echo $RANDOM"-"echo $RANDOM"-"echo $RANDOM`

$ echo $rndnum
30380-echo 21875-echo 14791-echo 32193-echo 11503


What is the right way to create the following (where f is any number)?



ffffffff-ffff-ffff-ffff-ffffffffffff









share|improve this question




















  • 4





    Random numbers are not necessarily unique.

    – JdeBP
    Feb 14 at 9:39











  • yes , seems , this number is from presto configuration ( prestodb.github.io/docs/current/installation/deployment.html )

    – yael
    Feb 14 at 9:41






  • 10





    Note that UUIDs are not just random numbers stringed together.

    – Kusalananda
    Feb 14 at 9:44






  • 9





    I've spent too many hours debugging scripts which assume "unlikely" is the same as "won't happen". If this is supposed to be a UUID then please do use an actual UUID, there are strict constraints on the way they are generated. If you could elaborate the reason you need this we might be able to help more.

    – Philip Couling
    Feb 14 at 9:51




















6















I want to create random unique numbers (UUIDs) as the following



node.id=ffffffff-ffff-ffff-ffff-ffffffffffff


First I tried this



$ rndnum=` echo $RANDOM"-"echo $RANDOM"-"echo $RANDOM"-"echo $RANDOM"-"echo $RANDOM`

$ echo $rndnum
30380-echo 21875-echo 14791-echo 32193-echo 11503


What is the right way to create the following (where f is any number)?



ffffffff-ffff-ffff-ffff-ffffffffffff









share|improve this question




















  • 4





    Random numbers are not necessarily unique.

    – JdeBP
    Feb 14 at 9:39











  • yes , seems , this number is from presto configuration ( prestodb.github.io/docs/current/installation/deployment.html )

    – yael
    Feb 14 at 9:41






  • 10





    Note that UUIDs are not just random numbers stringed together.

    – Kusalananda
    Feb 14 at 9:44






  • 9





    I've spent too many hours debugging scripts which assume "unlikely" is the same as "won't happen". If this is supposed to be a UUID then please do use an actual UUID, there are strict constraints on the way they are generated. If you could elaborate the reason you need this we might be able to help more.

    – Philip Couling
    Feb 14 at 9:51
















6












6








6








I want to create random unique numbers (UUIDs) as the following



node.id=ffffffff-ffff-ffff-ffff-ffffffffffff


First I tried this



$ rndnum=` echo $RANDOM"-"echo $RANDOM"-"echo $RANDOM"-"echo $RANDOM"-"echo $RANDOM`

$ echo $rndnum
30380-echo 21875-echo 14791-echo 32193-echo 11503


What is the right way to create the following (where f is any number)?



ffffffff-ffff-ffff-ffff-ffffffffffff









share|improve this question
















I want to create random unique numbers (UUIDs) as the following



node.id=ffffffff-ffff-ffff-ffff-ffffffffffff


First I tried this



$ rndnum=` echo $RANDOM"-"echo $RANDOM"-"echo $RANDOM"-"echo $RANDOM"-"echo $RANDOM`

$ echo $rndnum
30380-echo 21875-echo 14791-echo 32193-echo 11503


What is the right way to create the following (where f is any number)?



ffffffff-ffff-ffff-ffff-ffffffffffff






linux bash shell-script random uuid






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Feb 14 at 11:58









Jeff Schaller

45.1k1164147




45.1k1164147










asked Feb 14 at 9:34









yaelyael

2,82263180




2,82263180








  • 4





    Random numbers are not necessarily unique.

    – JdeBP
    Feb 14 at 9:39











  • yes , seems , this number is from presto configuration ( prestodb.github.io/docs/current/installation/deployment.html )

    – yael
    Feb 14 at 9:41






  • 10





    Note that UUIDs are not just random numbers stringed together.

    – Kusalananda
    Feb 14 at 9:44






  • 9





    I've spent too many hours debugging scripts which assume "unlikely" is the same as "won't happen". If this is supposed to be a UUID then please do use an actual UUID, there are strict constraints on the way they are generated. If you could elaborate the reason you need this we might be able to help more.

    – Philip Couling
    Feb 14 at 9:51
















  • 4





    Random numbers are not necessarily unique.

    – JdeBP
    Feb 14 at 9:39











  • yes , seems , this number is from presto configuration ( prestodb.github.io/docs/current/installation/deployment.html )

    – yael
    Feb 14 at 9:41






  • 10





    Note that UUIDs are not just random numbers stringed together.

    – Kusalananda
    Feb 14 at 9:44






  • 9





    I've spent too many hours debugging scripts which assume "unlikely" is the same as "won't happen". If this is supposed to be a UUID then please do use an actual UUID, there are strict constraints on the way they are generated. If you could elaborate the reason you need this we might be able to help more.

    – Philip Couling
    Feb 14 at 9:51










4




4





Random numbers are not necessarily unique.

– JdeBP
Feb 14 at 9:39





Random numbers are not necessarily unique.

– JdeBP
Feb 14 at 9:39













yes , seems , this number is from presto configuration ( prestodb.github.io/docs/current/installation/deployment.html )

– yael
Feb 14 at 9:41





yes , seems , this number is from presto configuration ( prestodb.github.io/docs/current/installation/deployment.html )

– yael
Feb 14 at 9:41




10




10





Note that UUIDs are not just random numbers stringed together.

– Kusalananda
Feb 14 at 9:44





Note that UUIDs are not just random numbers stringed together.

– Kusalananda
Feb 14 at 9:44




9




9





I've spent too many hours debugging scripts which assume "unlikely" is the same as "won't happen". If this is supposed to be a UUID then please do use an actual UUID, there are strict constraints on the way they are generated. If you could elaborate the reason you need this we might be able to help more.

– Philip Couling
Feb 14 at 9:51







I've spent too many hours debugging scripts which assume "unlikely" is the same as "won't happen". If this is supposed to be a UUID then please do use an actual UUID, there are strict constraints on the way they are generated. If you could elaborate the reason you need this we might be able to help more.

– Philip Couling
Feb 14 at 9:51












2 Answers
2






active

oldest

votes


















27














On Linux, the util-linux/util-linux-ng package offers a command to generate UUIDs: uuidgen.



$ uuidgen
5528f550-6559-4d61-9054-efb5a16a4de0


To quote the manual:




The uuidgen program creates (and prints) a new universally unique identifier (UUID) using the libuuid(3) library. The new UUID can reasonably be considered unique among all UUIDs created on the local system, and among UUIDs created on other systems in the past and in the future.



There are two types of UUIDs which uuidgen can generate: time-based UUIDs and random-based UUIDs. By default uuidgen will generate a random-based UUID if a high-quality random number generator is present. Otherwise, it will choose a time-based UUID. It is possible to force the generation of one of these two UUID types by using the -r or -t options.




Addendum: The OP had provided a link in the comments to the documentation for Presto DB. After a bit of searching, I found this related discussion where it is explicitly mentioned that the node.id property is indeed a UUID.





Adding the information provided by frostschutz in a comment:



As an alternative to the uuidgen/libuuid approach, you can make use of an interface exposed by the Linux kernel itself to generate UUIDs:



$ cat /proc/sys/kernel/random/uuid
00db2531-365c-415c-86f7-503a35fafa58


The UUID is re-generated on each request.






share|improve this answer





















  • 2





    The final touch would be printf 'node.id=%sn' "$( uuidgen )"

    – Kusalananda
    Feb 14 at 10:28













  • well done , this is very good answer

    – yael
    Feb 14 at 10:55






  • 15





    possible fallback if uuidgen is unavailable: cat /proc/sys/kernel/random/uuid

    – frostschutz
    Feb 14 at 10:59






  • 2





    @frostschutz that's much better -- that should've been the answer

    – mosvy
    Feb 14 at 13:05











  • @frostschutz I have added the information on this kernel interface to my answer. Thank you.

    – Haxiel
    Feb 14 at 13:32



















-4














IIUC, that will do what you want:



$ rndnum=$RANDOM-$RANDOM-$RANDOM-$RANDOM-$RANDOM
$ echo $rndnum


EDIT you can use shuf to create random string composed of substrings of predefined length:



$ rndnum=$(shuf -i 11111111-99999999 -n 1)-$(shuf -i 1111-9999 -n 1)-$(shuf -i 1111-9999 -n 1)-$(shuf -i 1111-9999 -n 1)-$(shuf -i 111111111111-999999999999 -n 1)
$ echo $rndnum
59053328-6621-4406-7679-910171932338





share|improve this answer


























  • Does this comply with the length of the OP's requirement. AFAIK, the length varies between -. The behavior of $RANDOM in your case would not be predictable ( I did not downvote FYI )

    – Inian
    Feb 14 at 9:42













  • No, it does not, thanks for noticing that.

    – Arkadiusz Drabczyk
    Feb 14 at 9:45











  • I understand the OP tried to use $RANDOM but you should never use it for creating unique numbers.

    – Philip Couling
    Feb 14 at 10:02











  • I've just answered OP's question.

    – Arkadiusz Drabczyk
    Feb 14 at 10:03






  • 6





    The OP asked for unique random numbers.

    – Philip Couling
    Feb 14 at 10:10












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
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f500572%2fcreate-unique-random-numbers-uuids-in-bash%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes









27














On Linux, the util-linux/util-linux-ng package offers a command to generate UUIDs: uuidgen.



$ uuidgen
5528f550-6559-4d61-9054-efb5a16a4de0


To quote the manual:




The uuidgen program creates (and prints) a new universally unique identifier (UUID) using the libuuid(3) library. The new UUID can reasonably be considered unique among all UUIDs created on the local system, and among UUIDs created on other systems in the past and in the future.



There are two types of UUIDs which uuidgen can generate: time-based UUIDs and random-based UUIDs. By default uuidgen will generate a random-based UUID if a high-quality random number generator is present. Otherwise, it will choose a time-based UUID. It is possible to force the generation of one of these two UUID types by using the -r or -t options.




Addendum: The OP had provided a link in the comments to the documentation for Presto DB. After a bit of searching, I found this related discussion where it is explicitly mentioned that the node.id property is indeed a UUID.





Adding the information provided by frostschutz in a comment:



As an alternative to the uuidgen/libuuid approach, you can make use of an interface exposed by the Linux kernel itself to generate UUIDs:



$ cat /proc/sys/kernel/random/uuid
00db2531-365c-415c-86f7-503a35fafa58


The UUID is re-generated on each request.






share|improve this answer





















  • 2





    The final touch would be printf 'node.id=%sn' "$( uuidgen )"

    – Kusalananda
    Feb 14 at 10:28













  • well done , this is very good answer

    – yael
    Feb 14 at 10:55






  • 15





    possible fallback if uuidgen is unavailable: cat /proc/sys/kernel/random/uuid

    – frostschutz
    Feb 14 at 10:59






  • 2





    @frostschutz that's much better -- that should've been the answer

    – mosvy
    Feb 14 at 13:05











  • @frostschutz I have added the information on this kernel interface to my answer. Thank you.

    – Haxiel
    Feb 14 at 13:32
















27














On Linux, the util-linux/util-linux-ng package offers a command to generate UUIDs: uuidgen.



$ uuidgen
5528f550-6559-4d61-9054-efb5a16a4de0


To quote the manual:




The uuidgen program creates (and prints) a new universally unique identifier (UUID) using the libuuid(3) library. The new UUID can reasonably be considered unique among all UUIDs created on the local system, and among UUIDs created on other systems in the past and in the future.



There are two types of UUIDs which uuidgen can generate: time-based UUIDs and random-based UUIDs. By default uuidgen will generate a random-based UUID if a high-quality random number generator is present. Otherwise, it will choose a time-based UUID. It is possible to force the generation of one of these two UUID types by using the -r or -t options.




Addendum: The OP had provided a link in the comments to the documentation for Presto DB. After a bit of searching, I found this related discussion where it is explicitly mentioned that the node.id property is indeed a UUID.





Adding the information provided by frostschutz in a comment:



As an alternative to the uuidgen/libuuid approach, you can make use of an interface exposed by the Linux kernel itself to generate UUIDs:



$ cat /proc/sys/kernel/random/uuid
00db2531-365c-415c-86f7-503a35fafa58


The UUID is re-generated on each request.






share|improve this answer





















  • 2





    The final touch would be printf 'node.id=%sn' "$( uuidgen )"

    – Kusalananda
    Feb 14 at 10:28













  • well done , this is very good answer

    – yael
    Feb 14 at 10:55






  • 15





    possible fallback if uuidgen is unavailable: cat /proc/sys/kernel/random/uuid

    – frostschutz
    Feb 14 at 10:59






  • 2





    @frostschutz that's much better -- that should've been the answer

    – mosvy
    Feb 14 at 13:05











  • @frostschutz I have added the information on this kernel interface to my answer. Thank you.

    – Haxiel
    Feb 14 at 13:32














27












27








27







On Linux, the util-linux/util-linux-ng package offers a command to generate UUIDs: uuidgen.



$ uuidgen
5528f550-6559-4d61-9054-efb5a16a4de0


To quote the manual:




The uuidgen program creates (and prints) a new universally unique identifier (UUID) using the libuuid(3) library. The new UUID can reasonably be considered unique among all UUIDs created on the local system, and among UUIDs created on other systems in the past and in the future.



There are two types of UUIDs which uuidgen can generate: time-based UUIDs and random-based UUIDs. By default uuidgen will generate a random-based UUID if a high-quality random number generator is present. Otherwise, it will choose a time-based UUID. It is possible to force the generation of one of these two UUID types by using the -r or -t options.




Addendum: The OP had provided a link in the comments to the documentation for Presto DB. After a bit of searching, I found this related discussion where it is explicitly mentioned that the node.id property is indeed a UUID.





Adding the information provided by frostschutz in a comment:



As an alternative to the uuidgen/libuuid approach, you can make use of an interface exposed by the Linux kernel itself to generate UUIDs:



$ cat /proc/sys/kernel/random/uuid
00db2531-365c-415c-86f7-503a35fafa58


The UUID is re-generated on each request.






share|improve this answer















On Linux, the util-linux/util-linux-ng package offers a command to generate UUIDs: uuidgen.



$ uuidgen
5528f550-6559-4d61-9054-efb5a16a4de0


To quote the manual:




The uuidgen program creates (and prints) a new universally unique identifier (UUID) using the libuuid(3) library. The new UUID can reasonably be considered unique among all UUIDs created on the local system, and among UUIDs created on other systems in the past and in the future.



There are two types of UUIDs which uuidgen can generate: time-based UUIDs and random-based UUIDs. By default uuidgen will generate a random-based UUID if a high-quality random number generator is present. Otherwise, it will choose a time-based UUID. It is possible to force the generation of one of these two UUID types by using the -r or -t options.




Addendum: The OP had provided a link in the comments to the documentation for Presto DB. After a bit of searching, I found this related discussion where it is explicitly mentioned that the node.id property is indeed a UUID.





Adding the information provided by frostschutz in a comment:



As an alternative to the uuidgen/libuuid approach, you can make use of an interface exposed by the Linux kernel itself to generate UUIDs:



$ cat /proc/sys/kernel/random/uuid
00db2531-365c-415c-86f7-503a35fafa58


The UUID is re-generated on each request.







share|improve this answer














share|improve this answer



share|improve this answer








edited Feb 14 at 13:30

























answered Feb 14 at 9:56









HaxielHaxiel

3,62811021




3,62811021








  • 2





    The final touch would be printf 'node.id=%sn' "$( uuidgen )"

    – Kusalananda
    Feb 14 at 10:28













  • well done , this is very good answer

    – yael
    Feb 14 at 10:55






  • 15





    possible fallback if uuidgen is unavailable: cat /proc/sys/kernel/random/uuid

    – frostschutz
    Feb 14 at 10:59






  • 2





    @frostschutz that's much better -- that should've been the answer

    – mosvy
    Feb 14 at 13:05











  • @frostschutz I have added the information on this kernel interface to my answer. Thank you.

    – Haxiel
    Feb 14 at 13:32














  • 2





    The final touch would be printf 'node.id=%sn' "$( uuidgen )"

    – Kusalananda
    Feb 14 at 10:28













  • well done , this is very good answer

    – yael
    Feb 14 at 10:55






  • 15





    possible fallback if uuidgen is unavailable: cat /proc/sys/kernel/random/uuid

    – frostschutz
    Feb 14 at 10:59






  • 2





    @frostschutz that's much better -- that should've been the answer

    – mosvy
    Feb 14 at 13:05











  • @frostschutz I have added the information on this kernel interface to my answer. Thank you.

    – Haxiel
    Feb 14 at 13:32








2




2





The final touch would be printf 'node.id=%sn' "$( uuidgen )"

– Kusalananda
Feb 14 at 10:28







The final touch would be printf 'node.id=%sn' "$( uuidgen )"

– Kusalananda
Feb 14 at 10:28















well done , this is very good answer

– yael
Feb 14 at 10:55





well done , this is very good answer

– yael
Feb 14 at 10:55




15




15





possible fallback if uuidgen is unavailable: cat /proc/sys/kernel/random/uuid

– frostschutz
Feb 14 at 10:59





possible fallback if uuidgen is unavailable: cat /proc/sys/kernel/random/uuid

– frostschutz
Feb 14 at 10:59




2




2





@frostschutz that's much better -- that should've been the answer

– mosvy
Feb 14 at 13:05





@frostschutz that's much better -- that should've been the answer

– mosvy
Feb 14 at 13:05













@frostschutz I have added the information on this kernel interface to my answer. Thank you.

– Haxiel
Feb 14 at 13:32





@frostschutz I have added the information on this kernel interface to my answer. Thank you.

– Haxiel
Feb 14 at 13:32













-4














IIUC, that will do what you want:



$ rndnum=$RANDOM-$RANDOM-$RANDOM-$RANDOM-$RANDOM
$ echo $rndnum


EDIT you can use shuf to create random string composed of substrings of predefined length:



$ rndnum=$(shuf -i 11111111-99999999 -n 1)-$(shuf -i 1111-9999 -n 1)-$(shuf -i 1111-9999 -n 1)-$(shuf -i 1111-9999 -n 1)-$(shuf -i 111111111111-999999999999 -n 1)
$ echo $rndnum
59053328-6621-4406-7679-910171932338





share|improve this answer


























  • Does this comply with the length of the OP's requirement. AFAIK, the length varies between -. The behavior of $RANDOM in your case would not be predictable ( I did not downvote FYI )

    – Inian
    Feb 14 at 9:42













  • No, it does not, thanks for noticing that.

    – Arkadiusz Drabczyk
    Feb 14 at 9:45











  • I understand the OP tried to use $RANDOM but you should never use it for creating unique numbers.

    – Philip Couling
    Feb 14 at 10:02











  • I've just answered OP's question.

    – Arkadiusz Drabczyk
    Feb 14 at 10:03






  • 6





    The OP asked for unique random numbers.

    – Philip Couling
    Feb 14 at 10:10
















-4














IIUC, that will do what you want:



$ rndnum=$RANDOM-$RANDOM-$RANDOM-$RANDOM-$RANDOM
$ echo $rndnum


EDIT you can use shuf to create random string composed of substrings of predefined length:



$ rndnum=$(shuf -i 11111111-99999999 -n 1)-$(shuf -i 1111-9999 -n 1)-$(shuf -i 1111-9999 -n 1)-$(shuf -i 1111-9999 -n 1)-$(shuf -i 111111111111-999999999999 -n 1)
$ echo $rndnum
59053328-6621-4406-7679-910171932338





share|improve this answer


























  • Does this comply with the length of the OP's requirement. AFAIK, the length varies between -. The behavior of $RANDOM in your case would not be predictable ( I did not downvote FYI )

    – Inian
    Feb 14 at 9:42













  • No, it does not, thanks for noticing that.

    – Arkadiusz Drabczyk
    Feb 14 at 9:45











  • I understand the OP tried to use $RANDOM but you should never use it for creating unique numbers.

    – Philip Couling
    Feb 14 at 10:02











  • I've just answered OP's question.

    – Arkadiusz Drabczyk
    Feb 14 at 10:03






  • 6





    The OP asked for unique random numbers.

    – Philip Couling
    Feb 14 at 10:10














-4












-4








-4







IIUC, that will do what you want:



$ rndnum=$RANDOM-$RANDOM-$RANDOM-$RANDOM-$RANDOM
$ echo $rndnum


EDIT you can use shuf to create random string composed of substrings of predefined length:



$ rndnum=$(shuf -i 11111111-99999999 -n 1)-$(shuf -i 1111-9999 -n 1)-$(shuf -i 1111-9999 -n 1)-$(shuf -i 1111-9999 -n 1)-$(shuf -i 111111111111-999999999999 -n 1)
$ echo $rndnum
59053328-6621-4406-7679-910171932338





share|improve this answer















IIUC, that will do what you want:



$ rndnum=$RANDOM-$RANDOM-$RANDOM-$RANDOM-$RANDOM
$ echo $rndnum


EDIT you can use shuf to create random string composed of substrings of predefined length:



$ rndnum=$(shuf -i 11111111-99999999 -n 1)-$(shuf -i 1111-9999 -n 1)-$(shuf -i 1111-9999 -n 1)-$(shuf -i 1111-9999 -n 1)-$(shuf -i 111111111111-999999999999 -n 1)
$ echo $rndnum
59053328-6621-4406-7679-910171932338






share|improve this answer














share|improve this answer



share|improve this answer








edited Feb 14 at 9:54

























answered Feb 14 at 9:38









Arkadiusz DrabczykArkadiusz Drabczyk

8,36521836




8,36521836













  • Does this comply with the length of the OP's requirement. AFAIK, the length varies between -. The behavior of $RANDOM in your case would not be predictable ( I did not downvote FYI )

    – Inian
    Feb 14 at 9:42













  • No, it does not, thanks for noticing that.

    – Arkadiusz Drabczyk
    Feb 14 at 9:45











  • I understand the OP tried to use $RANDOM but you should never use it for creating unique numbers.

    – Philip Couling
    Feb 14 at 10:02











  • I've just answered OP's question.

    – Arkadiusz Drabczyk
    Feb 14 at 10:03






  • 6





    The OP asked for unique random numbers.

    – Philip Couling
    Feb 14 at 10:10



















  • Does this comply with the length of the OP's requirement. AFAIK, the length varies between -. The behavior of $RANDOM in your case would not be predictable ( I did not downvote FYI )

    – Inian
    Feb 14 at 9:42













  • No, it does not, thanks for noticing that.

    – Arkadiusz Drabczyk
    Feb 14 at 9:45











  • I understand the OP tried to use $RANDOM but you should never use it for creating unique numbers.

    – Philip Couling
    Feb 14 at 10:02











  • I've just answered OP's question.

    – Arkadiusz Drabczyk
    Feb 14 at 10:03






  • 6





    The OP asked for unique random numbers.

    – Philip Couling
    Feb 14 at 10:10

















Does this comply with the length of the OP's requirement. AFAIK, the length varies between -. The behavior of $RANDOM in your case would not be predictable ( I did not downvote FYI )

– Inian
Feb 14 at 9:42







Does this comply with the length of the OP's requirement. AFAIK, the length varies between -. The behavior of $RANDOM in your case would not be predictable ( I did not downvote FYI )

– Inian
Feb 14 at 9:42















No, it does not, thanks for noticing that.

– Arkadiusz Drabczyk
Feb 14 at 9:45





No, it does not, thanks for noticing that.

– Arkadiusz Drabczyk
Feb 14 at 9:45













I understand the OP tried to use $RANDOM but you should never use it for creating unique numbers.

– Philip Couling
Feb 14 at 10:02





I understand the OP tried to use $RANDOM but you should never use it for creating unique numbers.

– Philip Couling
Feb 14 at 10:02













I've just answered OP's question.

– Arkadiusz Drabczyk
Feb 14 at 10:03





I've just answered OP's question.

– Arkadiusz Drabczyk
Feb 14 at 10:03




6




6





The OP asked for unique random numbers.

– Philip Couling
Feb 14 at 10:10





The OP asked for unique random numbers.

– Philip Couling
Feb 14 at 10:10


















draft saved

draft discarded




















































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.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f500572%2fcreate-unique-random-numbers-uuids-in-bash%23new-answer', 'question_page');
}
);

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







Popular posts from this blog

Human spaceflight

Can not write log (Is /dev/pts mounted?) - openpty in Ubuntu-on-Windows?

File:DeusFollowingSea.jpg