Head -c, –bytes=[-]NUM option prints the first NUM bytes of each file; with the leading ‘-‘, print all but the last NUM bytes of each file.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
## create a file with 100 lines > myfile; i=1; while [ $i -le 100 ]; \ do echo "$i" >> myfile; ((i++)); done ls -l myfile ## myfile1 is 292 bytes long ## default head myfile ## by default, returns top 10 lines ## NUM = positive integer head -c 50 myfile ## returns 1st 50 bytes of data ## NUM = negative integer head -c -50 myfile ## returns all file data except ## bottom 50 bytes of data rm myfile |