LinuxCommandLibrary

in

Test if value is in set

TLDR

View documentation for the for keyword

$ tldr for
copy

SYNOPSIS

No standard invocation. Shell syntax: for var in list; do cmds; done or case word in pats) cmds; esac

DESCRIPTION

There is no standard Linux command named in. Searches across common distributions (Ubuntu, Fedora, Arch) and core packages like coreutils, util-linux, and iproute2 reveal no executable or builtin shell command by this exact name in the default PATH.

Users often confuse in with shell scripting syntax. In Bash and POSIX sh, for var in list; do ... done iterates over a list, and case $var in pattern1) ... ;; esac uses in as a reserved word for pattern matching. These are not standalone commands but language constructs documented in bash(1) or sh(1).

If intending network-related checks (e.g., 'is IP in subnet?'), tools like ipcalc, netaddr Python module, or shell functions are used instead. Obscure or third-party tools named in may exist in specific repositories (e.g., a Perl script for CIDR checks), but they require explicit installation and are not standard.

Common similar commands include inotifywait(1) for filesystem event monitoring, install(1) for copying files with permissions, and ionice(1) for I/O scheduling. To verify, run which in or type in; it typically returns nothing or identifies a script if locally installed. For scripting needs, use grep, awk, or arrays.

CAVEATS

Not a standard command; likely shell syntax confusion. Use command -v in to check local availability. Avoid assuming existence in scripts.

COMMON MISCONCEPTIONS

Often mistaken for Python/JavaScript in operator or vi insert mode (i). For IP/subnet checks, prefer ip route get or cidr tools.

ALTERNATIVES FOR 'CONTAINS' CHECKS

String in file: grep -q; Number in range: awk or [[ $num -ge min && $num -le max ]]; Array membership: Bash printf '%s ' ${arr[@]} | grep -Fxq "$val".

HISTORY

No command history; in as shell keyword dates to Bourne shell (1977), enhanced in Bash (1989+) for arrays and patterns.

SEE ALSO

bash(1), sh(1), inotifywait(1), install(1), ionice(1), insmod(8)

Copied to clipboard