Linux Shell Loop : For (5x), While (endless) - One Line / Multiline

Submitted by Gast (nicht überprüft) on Di, 11/24/2020 - 02:38

While (endless, stop: CTRL+C)

while : 
 do 
  date
  echo "Hello "
  sleep 5
 done

Alternativ:

while : ; do date; echo "Hello "; sleep 6; done

 

For (5x):

for i in {1..5}
do
   echo "Number is $i "
   sleep 2
done

 Alternativ 1:

for i in {1..5}; do echo "Number is $i "; sleep 2; done

 

 Alternativ 2:

for i in {1..5}; do echo "Number is $i " && sleep 2; done

 

 

Neuen Kommentar schreiben

This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.