I dont see how your script would produce what you want since out isn changed in second loop...
The second error refers to while with j... your expr isnt correct: j=`expr 2*$1` so in fact there seem to be just that error...
while1 3
My logic is:
First Loop:
i=1 #
i=2 ##
i=3 ###
Second Loop:
j=2 * 3 =6
for 3<6 Out as it is ###
for 4<6 Out as it is last character trimmed ##
for 5<6 Out as it is last character trimmed #
Cant answer like that we havent the new script...
About your previous remark and my previous post, to work as you wanted the value in the second loop needed to be decremented which you did not so it would work only once then you would have always the same...
Here is the output and the script...
n12:/home/vbe/test $ sh 9007
9007[5]: test: 0403-004 Specify a parameter with this command.
9007[12]: 2*: 0403-053 Expression is not complete; more tokens expected.
n12:/home/vbe/test $ sh 9007 4
#
##
###
####
###
##
#
# the script 9007:
let i=1
let j=0
out=""
j=`expr 2*$1`
while [ $i -le $1 ]
do
out="$out"#""
echo $out
((i=i+1))
done
while [ $i -lt $j ]
do
out=${out%?} # missing in your first script...
print $out
# print ${out%?} # original print...
((i=i+1))
done