I was wondering if there is a more efficient way to get this task done. I am working with files with the number of lines ranging from a couple hundred thousand to a couple million. Say I know that lines 100,000 – 125,000 are the lines that contain the data I am looking for. I would like to know if there is a quick way to pull just these desired lines from the file. Right now I am using a loop with grep like this:
for ((i=$start_fid; i<=$end_fid; i++))
do
grep "^$i " fulldbdir_new >> new_dbdir${bscnt}
done
Which works fine its just is taking longer than I would like. And the lines contain more than just numbers. Basically each line has about 10 fields with the first being a sequential integer that appears only once per file.
I am comfortable writing in C if necessary.
sedcan do the job…sed -n '100000,125000p' inputEDIT: As per glenn jackman’s suggestion, can be adjusted thusly for efficiency…
sed -n '100000,125000p; 125001q' input