Command line GUID for Unix and Windows?

2020-02-26 03:45发布

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

5条回答
The star\"
2楼-- · 2020-02-26 03:53

'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
查看更多
Summer. ? 凉城
3楼-- · 2020-02-26 04:00

There are tons of online apps to do it.

If you are using PHP, you can use the uniqid function.

I found a pure Java program to do it at http://jug.safehaus.org/. That should work anywhere you can install Java.

查看更多
聊天终结者
4楼-- · 2020-02-26 04:08

In Windows XP, you can use the following in the command window.

uuidgen.exe
查看更多
做自己的国王
5楼-- · 2020-02-26 04:10

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.

查看更多
啃猪蹄的小仙女
6楼-- · 2020-02-26 04:12

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.

查看更多
登录 后发表回答