Saturday, July 26, 2014

head and tail in Linux/Unix

head
  1. head displays first lines of a file.
       - defaults to first 10 lines
       - argument allows different number to be shown
  2. Display the top of a file with the command below. How many lines do you count?
    
         head  filename 
         
  3. Now try this command and note how many lines are displayed this time?
    
         head -5  filename  
         

tail
  1. tail displays the last lines of the file.
         - defaults to 10 lines, or you can specified a number.
  2. Display the same file with the tail command. How is it different and how many lines do you count?
    
         tail  filename  
         
  3. Now try this command and note how many lines are displayed this time?
    
         tail -5  filename 
         

0 comments:

Post a Comment