V.T. Eric Layton Posted August 8, 2017 Share Posted August 8, 2017 From NixCraft... https://www.cyberciti.biz/faq/unix-linux-show-first-10-20-lines-of-file/ 5 Quote Link to comment Share on other sites More sharing options...
securitybreach Posted August 8, 2017 Share Posted August 8, 2017 Another nice tip 2 Quote Link to comment Share on other sites More sharing options...
V.T. Eric Layton Posted August 8, 2017 Author Share Posted August 8, 2017 Yeah. NixCraft is an excellent site. 1 Quote Link to comment Share on other sites More sharing options...
sunrat Posted August 8, 2017 Share Posted August 8, 2017 head -n is what I always used, where n is the number of lines. tail -n for the last n lines. 4 Quote Link to comment Share on other sites More sharing options...
wa4chq Posted August 8, 2017 Share Posted August 8, 2017 (edited) 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 August 8, 2017 by wa4chq 1 Quote Link to comment Share on other sites More sharing options...
sunrat Posted August 8, 2017 Share Posted August 8, 2017 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. 2 Quote Link to comment Share on other sites More sharing options...
securitybreach Posted August 9, 2017 Share Posted August 9, 2017 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. 1 Quote Link to comment Share on other sites More sharing options...
V.T. Eric Layton Posted August 9, 2017 Author Share Posted August 9, 2017 Actually, I normally use Head/Tail piped when searching through long log files. It works well. 2 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.