PDA

View Full Version : [ubuntu] commands: date, sed together ?



71GA
July 17th, 2011, 09:28 AM
Hello.

Can anyone tell me, what this returns and explain it a bit :)


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

ABCC
July 17th, 2011, 09:55 AM
Surely that should be


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


It calculates a sha sum of the date and the word Linux, then sed is used to only print the actual sum.

If you want to see it work, just run it step by step:


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


You could also use cut rather than sed:


date -u +%W$(uname) | sha256sum | cut -d' ' -f1