J.Doe J.Doe - 4 months ago 17
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.


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.