Jump to content

Unix / Linux: Show First 10 or 20 Lines Of a File


V.T. Eric Layton

Recommended Posts

Cool.....Tnx for the link, Eric. I tried head and tail. (tnx sunrat) I'm not sure what I'd use if for but tried it with a file I had just to see it's magic.....sure enough, it works! Thanks

Edited by wa4chq
  • Like 1
Link to comment
Share on other sites

tail is useful piped from dmesg when you need to see a device you just plugged in and want to know what the system sees it as. Especially useful if you're writing an image to a usb key with dd to avoid wiping out your other disks/partitions. It shows 10 lines if you omit the number parameter:

roger@siduction-brain:~$ dmesg |tail
[158342.332649] usbcore: registered new interface driver uas
[158343.391164] scsi 6:0:0:0: Direct-Access			  Patriot Memory   PMAP PQ: 0 ANSI: 0 CCS
[158343.392040] sd 6:0:0:0: Attached scsi generic sg3 type 0
[158344.789448] sd 6:0:0:0: [sdc] 62570496 512-byte logical blocks: (32.0 GB/29.8 GiB)
[158344.789684] sd 6:0:0:0: [sdc] Write Protect is off
[158344.789688] sd 6:0:0:0: [sdc] Mode Sense: 23 00 00 00
[158344.789856] sd 6:0:0:0: [sdc] No Caching mode page found
[158344.789863] sd 6:0:0:0: [sdc] Assuming drive cache: write through
[158344.818170]  sdc: sdc1
[158344.819337] sd 6:0:0:0: [sdc] Attached SCSI removable disk

Now I know I can write my image to /dev/sdc.

  • Like 2
Link to comment
Share on other sites

securitybreach

tail is useful piped from dmesg when you need to see a device you just plugged in and want to know what the system sees it as. Especially useful if you're writing an image to a usb key with dd to avoid wiping out your other disks/partitions. It shows 10 lines if you omit the number parameter:

roger@siduction-brain:~$ dmesg |tail
[158342.332649] usbcore: registered new interface driver uas
[158343.391164] scsi 6:0:0:0: Direct-Access			 Patriot Memory PMAP PQ: 0 ANSI: 0 CCS
[158343.392040] sd 6:0:0:0: Attached scsi generic sg3 type 0
[158344.789448] sd 6:0:0:0: [sdc] 62570496 512-byte logical blocks: (32.0 GB/29.8 GiB)
[158344.789684] sd 6:0:0:0: [sdc] Write Protect is off
[158344.789688] sd 6:0:0:0: [sdc] Mode Sense: 23 00 00 00
[158344.789856] sd 6:0:0:0: [sdc] No Caching mode page found
[158344.789863] sd 6:0:0:0: [sdc] Assuming drive cache: write through
[158344.818170] sdc: sdc1
[158344.819337] sd 6:0:0:0: [sdc] Attached SCSI removable disk

Now I know I can write my image to /dev/sdc.

 

Yeah I do still use it that way as I have like 8 drives in this machine so it's good to double check the drive letter when creating bootable images.

  • Like 1
Link to comment
Share on other sites

V.T. Eric Layton

Actually, I normally use Head/Tail piped when searching through long log files. It works well.

  • Like 2
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...