💾 Archived View for freeshell.de › tldr › if.gmi captured on 2022-06-11 at 22:00:58. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2022-04-28)

-=-=-=-=-=-=-

if

Performs conditional processing in shell scripts.
See also: `test`, `[`.

More information.

if {condition_command}; then {echo "Condition is true"}; fi
if ! {condition_command}; then {echo "Condition is true"}; fi
if {condition_command}; then {echo "Condition is true"}; else {echo "Condition is false"}; fi
if [[ -f {path/to/file} ]]; then {echo "Condition is true"}; fi
if [[ -d {path/to/directory} ]]; then {echo "Condition is true"}; fi
if [[ -e {path/to/file_or_directory} ]]; then {echo "Condition is true"}; fi
if [[ -n "${variable}" ]]; then {echo "Condition is true"}; fi
man [
Copyright © 2014—present the tldr-pages team and contributors.
This work is licensed under the Creative Commons Attribution 4.0 International License (CC-BY).

CC-BY