Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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?

share|improve this question
    
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
add comment

2 Answers

up vote 3 down vote accepted
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
share|improve this answer
    
SHA-265 -> SHA-256? –  Peter Mortensen Feb 18 '12 at 17:26
add comment

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 say "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...)

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.