LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

in

Shell keyword separating the loop variable from the list in for and select loops

TLDR

Iterate over a list of words
$ for fruit in apple banana cherry; do echo "$fruit"; done
copy
Iterate over a glob
$ for f in *.txt; do echo "$f"; done
copy
Iterate over command substitution
$ for user in $(cat users.txt); do echo "$user"; done
copy
Iterate over a brace-expansion range
$ for i in {1..10}; do echo "$i"; done
copy
Interactive menu with select
$ select opt in start stop quit; do echo "$opt"; done
copy

SYNOPSIS

for name in [words ...]; do commands; doneselect name in [words ...]; do commands; done

DESCRIPTION

in is a reserved word of the POSIX shell grammar, used as a delimiter between the loop variable and the word list in for and select compound commands and in case statements. It is not a standalone program and cannot be invoked directly; shells such as bash, zsh, dash, and ksh parse it as part of the surrounding control structure.Inside a for loop, the variable named before in is assigned successively to each word produced by the list after in (which may be literal words, glob expansions, command substitutions, or parameter expansions). When the word list is omitted entirely, the loop iterates over the positional parameters "$@".

INSTALL

yay -S in
copy

CAVEATS

in is a keyword, not an executable; `which in` will typically return nothing. It has no flags or options of its own. Behavior depends on the surrounding shell construct and on POSIX quoting/expansion rules.

HISTORY

in comes from the Bourne shell and has been part of the POSIX shell specification since its inception. It is inherited by all POSIX-compatible shells including bash, ksh, zsh, and dash, and by the C shell family in similar form.

SEE ALSO

for(1), while(1), do(1), done(1), read(1)

Braincup
Open source brain training for math, memory and focus
Braincup mini-games
41 mini-games · Apache-2.0
No ads · No tracking
Play in browser
Download Braincup on the App StoreGet Braincup on Google PlayGet Braincup on F-Droid
276 stars
From the maker of Linux Command Library
Copied to clipboard
Braincup
Open source brain training for math, memory and focus. 41 mini-games, from mental arithmetic to Sudoku, N-Back and Solo Chess.
Apache-2.0 licensed · No ads · No tracking · No account
From the maker of Linux Command Library
Download Braincup on the App StoreGet Braincup on Google PlayGet Braincup on F-Droid