Awk

11

    Decimal value 11.

011

    Octal 11, decimal value 9.

0x11

    Hexadecimal 11, decimal value 17. 


 gawk 'BEGIN { printf "d, %d\n", 011, 11, 0x11 }'
 9, 11, 17

Want to know which character sign is behind hex number 0x26? Solution:

 gawk 'BEGIN { printf "%c\n", 0x26 }'
 &

To replace all letters, numbers, parenthesis and "_" and "^" by "-" in the file head enter :

  nawk '{ gsub(/[a-zA-Z0-9"^""_""("")"]/, "+");print $0;}' head.csv 

To use awk to convert a Mac OS file to Unix, at the Unix prompt, enter:

  awk '{ gsub("\r", "\n"); print $0;}' macfile.txt > unixfile.txt

To convert a Unix file to Mac OS using awk, at the command line, enter:

  awk '{ gsub("\n", "\r"); print $0;}' unixfile.txt > macfile.txt

To replace the remove all lines starting with #, enter :

 awk '{if ( substr($0,1,1)!="#") print $0}' list_2mass.tsv

To replace the remove all lines starting with either # or carriage return or SPACE, enter :

 awk '{if (substr($0,1,1)!="#"&&substr($0,1,1)!='\n'&&substr($0,1,1)!=" ") print $0}' list_2mass.tsv