Sunday, April 27, 2014

head

  •   head command example

Output the first part of files, prints the first part (10 lines by default) of each file.

SYNTAX
      head [options]... [file]...


Examples

Extract the first 85 lines from a file:


$ head -5 file.txt

this is test1.
this is test2.
this is test3.
this is test4.
this is test5.


Extract lines 40-50 from a file, first using head to get the first 50 lines then tail to get the last 10:

$ head -50 file.txt | tail -10





Related Posts:

  • sort  sort command examples Sort a file in ascending order $ sort names.txt Sort a file in descending order $ sort -r names.txt Sort passwd file by 3rd field. $ sort -t: -k 3n /etc/passwd | more … Read More
  • shutdown   shutdown command examples Shutdown the system and turn the power off immediately. # shutdown -h now Shutdown the system after 10 minutes. # shutdown -h +10 Reboot the system using shutdown co… Read More
  • sed   sed command examples When you copy a DOS file to Unix, you could find \r\n in the end of each line. This example converts the DOS file format to Unix file format using sed command. $sed 's/.$//' filename … Read More
  • service service command example   Service command is used to run the system V init scripts. i.e Instead of calling the scripts located in the /etc/init.d/ directory with their full path, you can use the service command. … Read More
  • ssh   ssh command examples  Login to remote host ssh -l jsmith remotehost.example.com Debug ssh client ssh -v -l jsmith remotehost.example.com Display ssh client version $ ssh -V OpenSSH_3.9p1, OpenSSL 0.… Read More

0 comments:

Post a Comment