Hello:
I am new to shell script programming. Now I would like to select specific records block from a file. For example, current file "xyz.txt" is containing 1million records and want to select the block of records from line number 50000 to 100000 and save into a file. Can anyone suggest me how do I write a command in one line?
Thank you.
Try this
sed -n '50000,100000 p' file
#sed -n "<startline>,<endline> p" file
regards,
Ahamed
Try this
perl -ne 'print if $. >= 50000; exit if $. >= 100000;' xyz.txt>output_file
#!/bin/bash
# bash 4 tested
declare -i num=0
while read -r line
do
((num++))
if (( $num >50000 ));then
echo "$line"
fi
if (( $num == 100001 ));then
exit
fi
done <file > output