Skip to content

Instantly share code, notes, and snippets.

@ahpex
Created August 3, 2011 19:18
Show Gist options
  • Save ahpex/1123537 to your computer and use it in GitHub Desktop.
Save ahpex/1123537 to your computer and use it in GitHub Desktop.
Linux Commandline-Fu

Linux Commandline-Fu

Date and Time

Convert epoch timestamp to UTC

$ date -u -d @1312398568
Mi 3. Aug 19:09:28 UTC 2011

In vim one can move the cursor over the number and issue :!dump -u -d @<cword> in normal mode.

Formatting and Printing

Format the output of a command and save it to a PDF file

$ ls -la /dev | a2ps --center-title="Sample Report" -r2 -o - | ps2pdf - /tmp/test.pdf

Calculations

Convert decimal value to hex and use lowercase letters

$ echo "obase=16;7232811" | bc | tr "[:upper:]" "[:lower:]"

Convert hexadecimal value to decimal

$ echo "ibase=16;7FFF | bc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment