Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

1 Answer 1

up vote 2 down vote accepted

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
share|improve this answer

Your Answer

 
discard

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.