I'm trying to do a while loop into bash script but I don't know what's going on with the ed (text editor) when I tried to insert a varible in its arguments. As you can see, I'm using a loop as well, but the problem seem to be in the use of varibles inside ed command.
Here is the script code (obvious the awk and sed programs):
#!/bin/bash
x=1
y=5
SCRIPTDIR=~/bin
awk 'NR % 2==0' test > output1
awk -v n=5 '1; NR % n == 0 {print ""}' output1 > output1b
sed -i 's/\r//' output1b
while [ $x -le 50 ]; do
ed -s output1b <<< $"$xm$y\nw"
let x=x+5
let y=y+5
done