DaemonForums  

Go Back   DaemonForums > Miscellaneous > Programming

Programming C, bash, Python, Perl, PHP, Java, you name it.

Reply
 
Thread Tools Display Modes
  #1   (View Single Post)  
Old 28th August 2014
Mike-Sanders Mike-Sanders is offline
Fdisk Soldier
 
Join Date: Dec 2012
Posts: 52
Default Limit output to range of lines

Some handy information when you want to limit output to a given range of lines... Example, output only lines 1 to 20:

Code:
sed -n 1,20p file | next-tool...
__________________
www.tacoshack.xyz
Reply With Quote
  #2   (View Single Post)  
Old 9th November 2014
gso gso is offline
Port Guard
 
Join Date: Nov 2014
Posts: 35
Default

tail(1) command is is useful to pick up the last line:
Code:
tail -n1 file.txt
head(1) command similarly:
Code:
head -n1 file.txt
Reply With Quote
  #3   (View Single Post)  
Old 9th November 2014
soderlund soderlund is offline
New User
 
Join Date: Nov 2014
Posts: 9
Default

There is nothing you can't do with the standard text editor:

Code:
printf '<first line>,<last line>p\nQ\n' | ed -s <filename>
Or "n" instead of "p" for line numbers.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
ksh: wrap lines? Skinny OpenBSD General 11 3rd May 2013 11:30 PM
No range from new nic divadgnol67 OpenBSD General 2 25th October 2010 01:47 AM
ftp client port range kondziq FreeBSD General 1 16th June 2010 01:31 AM
Csh - range expansion? ivanatora Programming 8 4th November 2008 03:16 AM
Putting Lines to Together. bigb89 Programming 4 24th September 2008 03:59 AM


All times are GMT. The time now is 10:42 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Content copyright © 2007-2010, the authors
Daemon image copyright ©1988, Marshall Kirk McKusick