IsraelTorres

showtable.sh

Sep 9th, 2011
193
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/bash
  2. # Israel Torres
  3. # 1297648420
  4. # Sun Feb 13 17:53:40 PST 2011
  5. # Displays the tabbed table as follows:
  6. # CHAR_DEC NUM HEX OCT BIN / ASCII_DEC ASCII_HEX ASCII_OCT ASCII_BIN
  7.  
  8. echo -e "[CHAR]\t[NUM]\t[HEX]\t[OCT]\t[BIN]\t[ASC]\t[HEX]\t[OCT]\t[BIN]"
  9.  
  10. for ASC in {32..127}; do
  11.  
  12. CNT=$(($CNT+1))
  13.  
  14. CHR=$(printf \\$(printf '%03o' $ASC))
  15.  
  16. HEX=$(printf '%X\n' $ASC)
  17. OCT=$(printf '%o\n' $ASC)
  18. BIN=$(echo "ibase=10;obase=2;$ASC" | bc)
  19.  
  20. ASC_HEX=$(printf '%X\n' $CNT)
  21. ASC_OCT=$(printf '%o\n' $CNT)
  22. ASC_BIN=$(echo "ibase=10;obase=2;$CNT" | bc)
  23.  
  24. echo -n "$CHR"
  25. echo -ne "\t"
  26. echo -n $CNT
  27. echo -ne "\t"
  28. echo -n $ASC_HEX
  29. echo -ne "\t"
  30. echo -n $ASC_OCT
  31. echo -ne "\t"
  32. echo -n $ASC_BIN
  33.  
  34. echo -ne "\t"
  35. echo -n $ASC
  36. echo -ne "\t"
  37. echo -n $HEX
  38. echo -ne "\t"
  39. echo -n $OCT
  40. echo -ne "\t"
  41. echo -n $BIN
  42. echo -en "\n"  
  43.  
  44. done
RAW Paste Data