can any body give me the correct syntax of for loop to be used in vi editor in ubuntu.....
i know like this....:-

for (( initialisation;condition;increment ))
do
    "statements for do"
done

Recommended Answers

hi,

can you be more precise about what your trying to do?
what's the goal of the for loop?
are you writing a vi script, or are you using vi to write a shell script?

Jump to Post

All 4 Replies

hi,

can you be more precise about what your trying to do?
what's the goal of the for loop?
are you writing a vi script, or are you using vi to write a shell script?

echo "Pattern1"

for (( $i=0;$i<=5;$i++ ))
do
    for (( $j=0;$j<=i;$j++ ))
    do
        echo $j;
    done
    echo "";
done

//i want to print a pattern but it gives me a for syntax error......
for (( i=0; i<=5; i++ ))

i=0 is an assignment, as is i++ inside double parenthesis.

ya thnks it worked.....

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.