How can I extract a predetermined range of lines from a text file on Unix? -
i have ~23000 line sql dump containing several databases worth of data. need extract section of file (i.e. data single database) , place in new file. know both start , end line numbers of data want.
does know unix command (or series of commands) extract lines file between line 16224 , 16482 , redirect them new file?
sed -n 16224,16482p filename > newfile
from sed manual:
p - print out pattern space (to standard output). command used in conjunction -n command-line option.
n - if auto-print not disabled, print pattern space, then, regardless, replace pattern space next line of input. if there no more input sed exits without processing more commands.
addresses in sed script can in of following forms:
number specifying line number match line in input.
an address range can specified specifying 2 addresses separated comma (,). address range matches lines starting first address matches, , continues until second address matches (inclusively).
Comments
Post a Comment