Head

From Hackepedia
Jump to navigationJump to search

Head is a program that allows you to print the first X lines of a file. It looks a little like this:

$ head -4 /var/run/dmesg.boot                                         
OpenBSD 4.3 (GENERIC) #0: Sun May 11 13:04:18 CEST 2008
    [email protected]:/usr/src/sys/arch/i386/compile/GENERIC
cpu0: AMD Athlon(tm) 64 Processor 3500+ ("AuthenticAMD" 686-class, 512KB L2 cache) 2.33 GHz
cpu0:    FPU,V86,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,MMX,FXSR,SSE,SSE2


To get the last few lines of a file use tail. This can also be done with the programs sed and awk.