taT4Nix | Heads or Tails, Read between the lines..

Suppose, there is a file having 14 records and you want to copy only a range of records, like 5-12. So, let us denote 5 as lower bound ($LB) and 12 as upper bound ($UB). Here we go;

cat ${OLD_FILE} | tail -`expr $(cat ${OLD_FILE} | wc -l) - $LB + 1` | head -`expr $UB - $LB + 1` > ${NEW_FILE}

So, the original file is being referred to as ${OLD_FILE} and the newly created one as ${NEW_FILE}. This way, you would get range of lines of text from a file. If you feel there’s something better, you can always comment here.