Copy Limited rows from one file to another

Hi,

The file contains 1000 of rows can you please let me know
How to copy 1-10 and 30-40 rows from one file to another.

thanks
:slight_smile:

$1 - 1000 rows file
$2 - output file
for (( i = 1; i <= 10; i++ ))
do
sed -n "$i p" $1 >> $2
done
for (( i = 30; i <= 40; i++ ))
do
sed -n "$i p" $1 >> $2
done

or simply

sed -n '1,10p' INPUT > OUTPUT && sed -n '30,40p' INPUT >> OUTPUT

thanks its working