Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
up vote 4 down vote accepted

You can use the following:

while true 
   ls -ltr
   sleep 2 

The above can be broken with Ctrl-C

A single line:

while true; do ls -ltr; date; sleep 2; done
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.