builtin

ulimit

Inspect or set soft open-file limit where supported. Changing it in a subshell avoids constraining the parent. This is not a sandbox.

Formal Syntax & Structure

bash syntaxbash
ulimit -Sn [limit]

Parameters & Attributes

NameTypeDescription
limitintegerSoft limit within hard limit

Return Value

exit status

Inspect or set soft open-file limit where supported. Changing it in a subshell avoids constraining the parent. This is not a sandbox.

Working Example

Example Snippetbash
before=$(ulimit -Sn)( ulimit -Sn 64 || exit 1; printf 'child=%s\n' "$(ulimit -Sn)" ) || exit 1[[ $(ulimit -Sn) == "$before" ]] && printf 'parent unchanged\n'
Bash Reference