DEV Community

Discussion on: Shellscripting: Conditional Execution

Collapse
 
pstadler profile image
Patrick Stadler • Edited

I really enjoy using conditions in one-liners with shell:

# if file exists, source it
[ -f $HOME/.env-local ] && source $HOME/.env-local

# if directory doesn't exist, create it
[ -d ./test ] || mkdir ./test