Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Command line GUID for Unix and Windows?

Is there a command line tool for Unix and Windows that uses the same algorithm to create GUIDs for both platforms?

like image 837
Robert Gould Avatar asked Feb 20 '09 15:02

Robert Gould


People also ask

Where can I find Uuidgen?

I found that uuidgen.exe is present inside my C:\Program Files (x86)\Windows Kits\10\bin\10.0. 19041.0\x64 directory, probably because of some components that I have installed along with Visual Studio. So I simply added C:\Program Files (x86)\Windows Kits\10\bin\10.0.

Does Linux have a GUID?

Linux provides a lot of different tools to generate GUID. But one of the most simple and default installed tool is uuidgen .

What is the Windows command line?

The command line, also called the Windows command line, command screen, or text interface, is a user interface that's navigated by typing commands at prompts, instead of using a mouse. For example, the Windows folder in a Windows command line is "C:\Windows>" (as shown in the picture).


3 Answers

'e2fsprogs' project maintain uuidgen utility.

http://e2fsprogs.sourceforge.net/

It is already available on any Linux/BSD* distros.

For Windows I recommend install Cygwin, 'e2fsprogs' package available from there!

As report j4y this utility is available under MAC OS.

Just run:

  $ uuidgen -r  # random based UUID/GUID
  $ uuidgen -t  # time based UUID/GUID
like image 72
gavenkoa Avatar answered Nov 13 '22 07:11

gavenkoa


I don't know if there is a command line tool available, but you could simply write one in C# (it should run with Mono):

class Program
{
    static void Main(string[] args)
    {
        Console.WriteLine(System.Guid.NewGuid().ToString());
    }
}

You can easily modify the program to change formatting of the GUID, copy it to the clipboard or whatever fits your need.

like image 37
Dirk Vollmar Avatar answered Nov 13 '22 07:11

Dirk Vollmar


Something useful to know:

The byte order of Guid.ToByteArray() in C# and the SQL Server GUID type is:

        { 3, 2, 1, 0, 5, 4, 7, 6, 8, 9, 10, 11, 12, 13, 14, 15 };

An Oracle GUID created using SYS_GUID() and stored as RAW[16] is ordered:

        { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };

You may find this online GUID converter handy. I'm not sure if the source is available for your own use, but it shouldn't be too hard to figure it out.

like image 35
crb Avatar answered Nov 13 '22 06:11

crb