💾 Archived View for freeshell.de › tldr › if.gmi captured on 2022-04-28 at 18:48:18. Gemini links have been rewritten to link to archived content
-=-=-=-=-=-=-
Performs conditional processing in shell scripts.
See also: `test`, `[`.
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).