50 Most Frequently Used UNIX / Linux Commands (With Examples)

Several pearl in 50 Most Frequently Used UNIX / Linux Commands (With Examples)

  • Add line number for all non-empty-lines in a file
    $ sed '/./=' thegeekstuff.txt | sed 'N; s/\n/ /'
  • Remove duplicate lines using awk
    $ awk '!($0 in array) { array[$0]; print }' temp
    

     

  • Print all lines from /etc/passwd that has the same uid and gid
    $awk -F ':' '$3==$4' passwd.txt
    
  • Go to the 143rd line of file
    $ vim +143 filename.txt
    

     

  • Go to the first match of the specified
    $ vim +/search-term filename.txt
    

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.