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:

  • man   man command examples Display the man page of a specific command.    $ man crontab When a man page for a command is located under more than one section, you can view the man page for that command from… Read More
  • kill kill command examples Use kill command to terminate a process. First get the process id using ps -ef command, then use kill -9 to kill the running Linux process as shown below. You can also use killall, pkill, xkill … Read More
  • less    less command examples less is very efficient while viewing huge log files, as it doesn’t need to load the full file while opening. $ less huge-log-file.log One you open a file using less command, follow… Read More
  • mysql  mysql  command example mysql is probably the most widely used open source database on Linux. Even if you don’t run a mysql database on your server, you might end-up using the mysql command ( client ) to connect … Read More
  • ifconfig ifconfig command examples Use ifconfig command to view or configure a network interface on the Linux system. View all the interfaces along with status. $ ifconfig -a Start or stop a specific interface using up and… Read More

0 comments:

Post a Comment