Infinite loop in Terminal (ksh) to launch commands

I'm trying to create a loop in terminal to launch every second during the execution of an script the following command. I don't want to create the loop in .sh script file, i'm trying to do in the prompt.

I tried this but doesn't work:

for 1
> do
> ls -ltr
> date
> sleep 2
> done

Error message: ksh: 1: is not an identifier

I'm using korn shell in AIX.

1 Answer

You can use the following:

while true
do ls -ltr date sleep 2
done

The above can be broken with Ctrl-C

A single line:

while true; do ls -ltr; date; sleep 2; done

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like