Top 13 proven Unix commands absolutely helpful for Files

The below list I have selected because when I attended for interviews asked these in many companies. So named as top 13 selected UNIX commands you may apply on files. The other way when you are new to UNIX the tips given in UNIX/Linux Operating system – Beginner to Advanced really give lot of benefits. Working on the files is very common practice for data warehousing developers.

  • $> head   -1  sample.txt    :=> To get top one line
  • $> sed    '2,$d'   sample.txt    :=> To get first 2 lines
  • $> tail   -1     sample.txt     :=> To get last one line
  • $> tail   -n '2p'   sample.txt   :=> To get 2nd line of file
  • $>  head  -4  sample.txt   | tal -1 :=> To get fourth line of file
  • $> sed '1d' sample.tx  :=> To remove first line of file
  • $> sed  -i  '1d' sample.txt   :=> After deleting update the same file
  • $> sed  -i  '5,7d'   sample.txt  :=>Remove lines from 5 to 7
  • $> sed -n   '35p'     sample.txt | wc -c  :=> To get 35 number of chars in any line of the file
  • $> cut  -f4   -d ' '   ==> To get 4th word from each line of file delimiter is spaces
  • $> echo 'unix'  | rev  :  ==> To get word in reverse - xinu
  • $> unzip   -j  sample.txt  :=> To unzip a file
  • $> file   -i   file.zip   :=> To get information about file

Also Read | More Unix Sed commands

Advertisements

Author: Srini

Experienced software developer. Skills in Development, Coding, Testing and Debugging. Good Data analytic skills (Data Warehousing and BI). Also skills in Mainframe.