repeat

Loop command to repeat an action. Zsh only.

Syntax
      repeat word do list done

      repeat word sublist

Key
   word is expanded and treated as an arithmetic expression, which must evaluate to a number n.
   list is then executed n times.


   The second form is a non-standard short form of repeat.
   This should not be used where portability of shell code is a concern. 

The repeat syntax is disabled by default when the shell starts in a mode emulating another shell. It can be enabled with the command ‘enable -r repeat’

repeat is a Zsh complex command, repeat is a reserved word.

Examples

 

% repeat 5 echo Hello world

% repeat 5 {echo "Hello world"; echo 'How are you!'}

Copy 20 UUIDs to the clipboard:

% {repeat 20 uuidgen} | pbcopy

“First rate people hire other first rate people. Second rate people hire third rate people. Third rate people hire fifth rate people” ~ André Weil

Related macOS commands

Local man page: repeat - Command line help page on your local machine.
diff - Display the differences between two files.


 
Copyright © 1999-2026 SS64.com
Some rights reserved