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
> doneError 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
doneThe above can be broken with Ctrl-C
A single line:
while true; do ls -ltr; date; sleep 2; done