Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions bash.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,13 +166,13 @@ else
echo "Your name is your username"
fi

# To use && and || with if statements, you need multiple pairs of square brackets:
# You can use && and || with if statements:
read age
if [[ "$name" == "Steve" ]] && [[ "$age" -eq 15 ]]; then
if [[ "$name" == "Steve" && "$age" -eq 15 ]]; then
echo "This will run if $name is Steve AND $age is 15."
fi

if [[ "$name" == "Daniya" ]] || [[ "$name" == "Zach" ]]; then
if [[ "$name" == "Daniya" || "$name" == "Zach" ]]; then
echo "This will run if $name is Daniya OR Zach."
fi

Expand Down Expand Up @@ -411,7 +411,7 @@ do
done

# while loop:
while [ true ]
while [[ true ]]
do
echo "loop body here..."
break
Expand Down