Head Command
head command by default displays the first 10 lines of a file.
display 20 lines in a file
head -n 20 <file_name>
or you can also use the below
head -20 <file_name>
Display 200 bytes of data from the file
head -c 200 <file_name>
Skill last 28 lines // it only skips the last 28 lines
head -n -28 <file_name>
-- Head command to fetch lines - particular lines using pipe "|" symbol
head -n 23 movies.txt | tail -n 8
-- now we want to display only those movies that has 2009 as their year
head -n 23 movies.txt | tail -n 8 | grep 2009
$ head -n 10 movies.txt | grep 2010
Search in process result
// this will display only those process that have the keywork monitor in them
ps -ef | grep monitor
Display only specific file or folder
ls -l | grep -i Folder // -i says ignore case -- non case senstive.
Comments
Post a Comment