Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Bash function to generate an UUID

42 views
Skip to first unread message

Cecil Westerhof

unread,
Sep 13, 2013, 2:34:38 PM9/13/13
to
I wrote a BASH function to generate an UUID:
    http://tinyurl.com/BASHScripting

I know that there is uuidgen, but it is also about the exercise.

--
Cecil Westerhof
Senior Software Engineer
LinkedIn: http://www.linkedin.com/in/cecilwesterhof

Jasen Betts

unread,
Sep 14, 2013, 2:11:57 AM9/14/13
to
On 2013-09-13, Cecil Westerhof <Ce...@decebal.nl> wrote:
> I wrote a BASH function to generate an UUID:
>     http://tinyurl.com/BASHScripting
>
> I know that there is uuidgen, but it is also about the exercise.

Doesn't work.

--
⚂⚃ 100% natural

--- news://freenews.netfront.net/ - complaints: ne...@netfront.net ---

Cecil Westerhof

unread,
Sep 14, 2013, 3:52:20 AM9/14/13
to
Op zaterdag 14 sep 2013 08:11 CEST schreef Jasen Betts:

> On 2013-09-13, Cecil Westerhof <Ce...@decebal.nl> wrote:
>> I wrote a BASH function to generate an UUID:
>>     http://tinyurl.com/BASHScripting
>>
>> I know that there is uuidgen, but it is also about the exercise.
>
> Doesn't work.

What does not work?

Jasen Betts

unread,
Sep 14, 2013, 4:28:26 AM9/14/13
to
On 2013-09-14, Cecil Westerhof <Ce...@decebal.nl> wrote:
> Op zaterdag 14 sep 2013 08:11 CEST schreef Jasen Betts:
>
>> On 2013-09-13, Cecil Westerhof <Ce...@decebal.nl> wrote:
>>> I wrote a BASH function to generate an UUID:
>>>     http://tinyurl.com/BASHScripting
>>>
>>> I know that there is uuidgen, but it is also about the exercise.
>>
>> Doesn't work.
>
> What does not work?
>

"What?" is the main problem:



LinkedIn

Home
What is LinkedIn?
Join Today
Sign In

BASH (Nederlands)
BASH (Nederlands)
72 members

Join
Information and settings

Discussions
Promotions
Search

About the BASH (Nederlands) Group
This group is for people who could use or give help using the BASH shell. There will be interesting scripts and a handy library with functions will be developed.

BASH is... more »
Have something to say?

Join LinkedIn for free to participate in the conversation. When you join, you can comment and post your own discussions.

Cecil W.
How to start the Bash Open Source project. Manager's Choice

Cecil W.

Senior Software Engineer

I have been thinking to put my Bash functions in an Open Source library. Properly on GitHub. I would like to get some input in how to...
18 days ago
Cecil W.
What would you like to see covered in this group? Manager's Choice

Cecil W.

Senior Software Engineer

To serve the group optimal, it would be nice to know what the members find useful to be treated. So reply on this message with what you...
3 months ago

Popular

Cecil W.
Nicely formatted list of postscript functions.

Cecil W.

Senior Software Engineer

One of the things I am also busy with is postscript programming. Before a function there is a comment in the following format:
% input parameters 2 spaces function name 2 spaces output parameters

It is very handy to have a nicely formatted ...
decebal.nl decebal.nl

Like (1)
Comment (10)
Follow
1 month ago

Cecil W. likes this
See all 10 comments
Cecil W.

Cecil W. " I always use capitals for variables that are read-only. ... "
14 days ago

Chris J.

Chris J. " I very rarely use all caps for variable names. All except one of of BASH's own variables are all caps; there is too great a chance of a ... "
9 days ago

Chris J.

Chris J. " Avoid the "Advanced" Bash Scripting Guide like the plague. It is full of misinformation, bad practices and outright errors. "
9 days ago

Cecil W.
What would you like to see covered in this group?

Cecil W.

Senior Software Engineer


To serve the group optimal, it would be nice to know what the members find useful to be treated.
So reply on this message with what you are dying for to get help for, or just would like to know.
And if someone mentions a subject you find ...
Like
Comment (6)
Follow
3 months ago
See all 6 comments
Cecil W.

Cecil W. " Nederland should be deleted, but that is not possible: you can only change things one time. :-( Maybe I should contact LinkedIn again. ... "
16 days ago

Valentin B.

Valentin B. " The use of #sh would only be useful on legacy systems of course. Writing #sh means making the code as portable as possible which will run ... "
15 days ago

Cecil W.

Cecil W. " Ah, okay. I thought you mend something else beside portability. ... "
15 days ago

Cecil W.
Fetch From Youtube

Cecil W.

Senior Software Engineer


You can download video's from YouTube with youtube-dl. I wrote a script
around it to make it easier/smoother.

# Needed
# - External programs
# - youtube-dl
function fetchFromYouTube {
local -r COMMAND=youtube-dl
...
decebal.nl decebal.nl

Like (2)
Comment (3)
Follow
26 days ago

Cecil W., Valentin B. like this
Valentin B.

Valentin B. " Hi Cecil, ... "
25 days ago

Valentin B.

Valentin B. " @Cecil, btw why are you storing the 'youtube-dl' command in a variable? I personally don't see the benefit doing so. Any particular reason? "
25 days ago

Cecil W.

Cecil W. " ... "
25 days ago

Cecil W.
When to use an alias and when a function?

Cecil W.

Senior Software Engineer


I always use an alias for simple things that do not need parameters. For example:
alias census='who | wc -l'

When is it better to use an alias and when a function? Or is it mostly about what your preferences are?
Like
Comment (2)
Follow
1 month ago
Chris J.

Chris J. " As the bash man page says: ... "
25 days ago

Cecil W.

Cecil W. " ... "
25 days ago

Cecil W.
Getting a Random Number.

Cecil W.

Senior Software Engineer


You can get a random number with ${RANDOM}. But I find there are a few
shortcomings in this:
- The randomness is not very good.
- It only uses 15 bits.

That is why I wrote a function which uses /dev/urandom and generates a
32 bits ...
decebal.nl decebal.nl

Like (2)
Comment
Follow
27 days ago

Cecil W., James C. like this
Cecil W.
Get MAC Address.

Cecil W.

Senior Software Engineer


Sometimes you want to have the MAC address of your network card(s).
Therefore I made this little alias. For every network card it displays
the interface name with the corresponding MAC address. Nothing fancy,
but useful nevertheless I ...
Like
Comment (10)
Follow
1 month ago
See all 10 comments
Cecil W.

Cecil W. " ... "
1 month ago

Cecil W.

Cecil W. " ... "
1 month ago

Cecil W.

Cecil W. " ... "
1 month ago

Cecil W.
Sharing code on GitHub?

Cecil W.

Senior Software Engineer


I could share code on GitHub. Would that be handy?

Like
Comment (1)
Follow
3 months ago
Fikri R.

Fikri R. " Very, I could learn one thing or an other. ... "
3 months ago

Cecil W.
Hoeveel mails zijn er gisteren verstuurd?

Cecil W.

Senior Software Engineer

Door op te nemen in je crontab:
15 0 * * * echo "Er zijn op $(date --date='-1 days' '+\%F') $(grep "^$(date --date='-1 days' '+\%b \%_d').* postfix/smtp\[.* status=sent" /var/log/mail | wc -l) emails ...
Like
Comment (9)
Follow
November 12, 2011
See all 9 comments
Cecil W.

Cecil W. " @Frank Ik probeer vandaag nog naar die andere twee mogelijkheden te kijken. "
December 3, 2011

Pascal V.

Pascal V. " interessant :) dergelijke informatie via bash ophalen is nais! de bash-groep inspireert voor meer experimenteren met bash! tnx! "
April 2, 2012

Cecil W.

Cecil W. " Leuk dat het een inspiratie was. Indien je problemen of oplossingen hebt: post ze hier. "
April 3, 2012

Cecil W.
Waarom krijg ik teveel open bestanden als ik code in een functie stop?

Cecil W.

Senior Software Engineer


Ik heb de volgende code:
#!/usr/bin/env bash

set -o errexit
set -o nounset

declare LOOP_STEPS=2000
declare -r REQUIRED_STRING="required time"

declare day
declare -i end
declare i
declare ...
Like
Comment (13)
Follow
December 3, 2011
See all 13 comments
Oscar R.

Oscar R. " @Frank, ... "
December 7, 2011

Oscar R.

Oscar R. " Gloeiende... ik had bovenstaande bericht nog flink ge-edit. Gooit Linked-in dat weg met een "Sorry, er ging iets fout-melding". En natuurlijk ... "
December 7, 2011

Frank I.

Frank I. " @Oscar Ik vond het bericht dat je schreef verhelderend, dus dank je wel. Ik ga dit later nog een keer lezen, want ergens valt het kwartje nog ... "
December 8, 2011

Cecil W.
Meerdere waardes krijgen uit een subshell

Cecil W.

Senior Software Engineer


In een bepaald script heb ik de minuten, seconden en dag in de maand
nodig. Oorspronkelijk deed ik dit met:
temp=$(date '+%M %S %d')
minutes=${temp:0:2}
seconds=${temp:3:2}
day=${temp:6:2}

Echter een veel duidelijkere manier ...
Like
Comment (6)
Follow
December 3, 2011
See all 6 comments
Cecil W.

Cecil W. " Daar is niets mis mee. ;-} Dat zouden meer mensen moeten doen. ... "
December 6, 2011

Frank I.

Frank I. " misschien omdat het spawnen van een subshell intensiever is dan string manipulatie. ... "
December 6, 2011

Cecil W.

Cecil W. " Maar ik doe in beide gevallen $(date '+%M %S %d'). ... "
December 6, 2011

SHOW MORE DISCUSSIONS
About this Group

Created: July 19, 2009
Type: Professional Group
Members: 72

Owner: Cecil W.

Feedback

Help Center
About
Press
Blog
Careers
Advertising
Talent Solutions
Tools
Mobile
Developers
Publishers
Language
SlideShare

LinkedIn Updates
LinkedIn Influencers
LinkedIn Jobs
Jobs Directory
Company Directory
Groups Directory
Title Directory

LinkedIn Corporation © 2013

User Agreement
Privacy Policy
Community Guidelines
Cookie Policy
Copyright Policy

Cecil Westerhof

unread,
Sep 14, 2013, 5:54:04 AM9/14/13
to
Op zaterdag 14 sep 2013 10:28 CEST schreef Jasen Betts:

> On 2013-09-14, Cecil Westerhof <Ce...@decebal.nl> wrote:
>> Op zaterdag 14 sep 2013 08:11 CEST schreef Jasen Betts:
>>
>>> On 2013-09-13, Cecil Westerhof <Ce...@decebal.nl> wrote:
>>>> I wrote a BASH function to generate an UUID:
>>>>     http://tinyurl.com/BASHScripting
>>>>
>>>> I know that there is uuidgen, but it is also about the exercise.
>>>
>>> Doesn't work.
>>
>> What does not work?
>>
>
> "What?" is the main problem:
>
>
>
> LinkedIn
>
> Home
> What is LinkedIn?
> Join Today
> Sign In
>
> BASH (Nederlands)
> BASH (Nederlands)
> 72 members

[Removed excessive information]

You go from one extreme to another. First you say ‘Doesn't work.’
Which says nothing, then you give a quite excessive load of
information. In both cases you could just have said that you do not
have a LinkedIn account. Next time I'll be more clear that I posted it
on LinkedIn.

What *is* strange, is that the post (and several others) are not shown
when you are not logged in to LinkedIn.

Thad Floryan

unread,
Sep 14, 2013, 7:22:25 PM9/14/13
to
On 9/14/2013 2:54 AM, Cecil Westerhof wrote:
> [...]
> What *is* strange, is that the post (and several others) are not shown
> when you are not logged in to LinkedIn.

Which indicates LinkedIn is the *WRONG VENUE* to use for
software distribution which is announced in a public venue
such as Usenet.

Suggest hosting your software on a publicly accessible website
(perhaps your own website or any of the many free ones that can
be found with a simple search) or stop announcing "hidden" and
non-publicly-accessible items hosted on LinkedIn.

Thad

Cecil Westerhof

unread,
Sep 15, 2013, 11:45:09 AM9/15/13
to
Op zondag 15 sep 2013 01:22 CEST schreef Thad Floryan:

> On 9/14/2013 2:54 AM, Cecil Westerhof wrote:
>> [...] What *is* strange, is that the post (and several others) are
>> not shown when you are not logged in to LinkedIn.
>
> Which indicates LinkedIn is the *WRONG VENUE* to use for
> software distribution which is announced in a public venue
> such as Usenet.

I find it very strange, because I always thought that in an open group
everyone could read the postings. (And for some it is the case, but
not all. I have to delve into that.)


> Suggest hosting your software on a publicly accessible website
> (perhaps your own website or any of the many free ones that can
> be found with a simple search) or stop announcing "hidden" and
> non-publicly-accessible items hosted on LinkedIn.

The script with the functions can be downloaded at:
http://www.decebal.nl/bash/sources/random.sh

Properly I am going to place the code also on GitHub.
0 new messages