0

What is the output of date -u +%W$(uname)|sha256sum|sed 's/\W//g' (on Arch Linux if it matters)?
How do I find that out?

  • The best way to find out what is to run it. The best way to find out why is to read the documentation of the three commands involved. – Gilles Jan 7 '11 at 18:34
  • 4
    Although, if you truly haven't seen the commands before, it might be a better idea to read the documentation first. One does not want to get into the habit of simply running any command they come across. – Steven D Jan 7 '11 at 20:04
3
date -u %W

Displays the current week of the year.

uname

Displays the kernel name.

sha256sum

Generates a SHA-256 Hash Sum.

sed 's/\W//g'

Cuts out all non-word characters.

The |'s are redirecting the output of the first command to the appending command.

Enter the line in a terminal, f.e. gnome-terminal or xterm:

date -u +%W$(uname)|sha256sum|sed 's/\W//g'

Depending on the date and the operating system installed, this will output different hashes, like this:

2aa4cb287b8a9314116f43b5e86d892d76a9589559aa69ed382e8f5dc493d955
2

1. The 'uname' part

To answer the first question, the crucial thing is what uname without a parameter returns on Arch Linux. The man page does not define it, but uname Command says it is equivalent to uname -s:

-s   Displays the system name. This flag is on by default.

For -s, the man page says "print the kernel name". On Arch Linux uname returns

Linux

whereas on, for example, Cygwin uname returns something like:

CYGWIN_NT-5.2-WOW64

2. The 'date' part

date -u +%W returns the week number. As the last part ("Linux") is a fixed string, the final output depends on which week the command line is run in (the hash is computed on for example "07Linux"). With this knowledge the output can also be computed on Cygwin.

3. An example

The week number for 2012-02-18 is 7 and date -u +%W`uname` returns (has a leading zero, but this is expected for the task at hand)

07Linux

and the output from sha256sum (a SHA-2 hash) is:

4a65f65b40cc2b0a7aaa726e895d72425ede255021e2ce3e935dd2719e4d33b9

On Cygwin it can be computed as:

echo '07Linux'|sha256sum|sed 's/\W//g'

(This actually worked when I tried to register at ArchWiki...)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy