J.Doe J.Doe - 1 year ago 75
Linux Question

How to loop a statement in linux

I'm trying to loop a statement/output in linux. So in my ssh directory if I do ls. There is a file call hello.c which prints Hello James. What i'm trying to do is a for loop that prints it 4 times.

This is what i've tried.

for((int i=1;i<=4;i++));
echo $i

However nothing is printing.

Answer Source

Bash as a programming language, is dynamically typed, so there are no type declarations. So you can remove the type declaration from the line bellow:

for((int i=1;i<=4;i++));

i.e. change it to


Additionally, are you sure that you can call the program by saying ./hello.c? This is usually the source file and is not executable.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download