auto increment

Hello

Does anyone know how to auto-increment the value of a variable, preferably using awk or sed?

I need to read values from a file and auto-increment those values to use them as line numbers
I'd be doing:

while read line do
# auto-increment
sed -n${line}p file> file1
done <original

Thanks

Hi,

for i in {5..9}
do
  sed -n "${i}p" file
done

if your shell doesn't support {..}-syntax use
"seq" instead. See "man seq"

HTH Chris

Thanks for your reply but i think you misunderstood my question
I need to read values from my file, so i'm using: while read line do
Then the value stored in "line" must be incremented in one
and now i use sed -n${line}p file> file1
thanks

Something like

let line++
sed -n "${line}p"

in that case i'd use:
let "line=$line+1"

the problem is that i don't have "let" in ms dos and i need to run this script in ms dos
Therefore i was asking is someone knows how to do it with awk or sed (for example)

Fine, little misunderstanding. Use:

awk -v line=$line 'BEGIN{line++}NR==line{print}' file

Simpler and in sed:

sed -n "$line{n;p}" file