2.2.2 Important Syntax Flashcards
1
Q
How do you get the current date in BASH?
A
DATE=$(date +"%y-%m-%d")
2
Q
How do you write an if statement in bash?
A
if [ condition ]; then
# code
fi
3
Q
What are some loops in Bash?
A
for, while, and until loops
4
Q
How do you write a for loop?
A
for i in 1 2 3 4 5 do echo "Iteration $i" done
5
Q
How do you write a while loop
A
#!/bin/sh counter=1 while [ $counter -le 5 ] do echo "Counter: $counter" 36 counter=$((counter + 1)) done
6
Q
How do you write an until loop
A
Just an inifnite loops that only ends on exit command