file-test

Bash -k — sticky mode bit

Checks the sticky permission bit. On shared directories it generally restricts removal or renaming of entries; the test itself does not evaluate the complete deletion policy. Use a private directory, not a system directory. Run the example independently in a fresh private directory. Expected output (one item per line): set=0; cleared=1.

Formal Syntax & Structure

bash syntaxbash
[[ -k path ]]

Parameters & Attributes

NameTypeDescription
pathpathFile or directory pathname to inspect.

Return Value

exit status

0 for a true condition; 1 for a false condition. Invalid expressions may fail differently.

Working Example

Example Snippetbash
mkdir samplechmod 1700 sample[[ -k sample ]]; printf 'set=%s\n' "$?"chmod 0700 sample[[ -k sample ]]; printf 'cleared=%s\n' "$?"
Bash Reference