# Essential Bash Scripting Flashcards
Table of Contents
- Shell Scripting Flashcards
- What is the shebang line for a bash script? drill shell_scripting
- How do you declare a variable in bash? drill shell_scripting
- What is the syntax for an if statement in bash? drill shell_scripting
- How do you access command-line arguments in a bash script? drill shell_scripting
- What is the syntax for a for loop in bash? drill shell_scripting
- How do you define a function in bash? drill shell_scripting
- What command is used to read user input in bash? drill shell_scripting
- How do you perform arithmetic operations in bash? drill shell_scripting
- What is the purpose of the 'export' command in bash? drill shell_scripting
- How do you redirect output to a file in bash? drill shell_scripting
Shell Scripting Flashcards
What is the shebang line for a bash script? drill shell_scripting
Front
What is the shebang line for a bash script?
Back
#!/bin/bash
How do you declare a variable in bash? drill shell_scripting
Front
How do you declare a variable in bash?
Back
variable_name=value
(No spaces around the equal sign)
What is the syntax for an if statement in bash? drill shell_scripting
Front
What is the syntax for an if statement in bash?
Back
if [ condition ]; then # commands elif [ condition ]; then # commands else # commands fi
How do you access command-line arguments in a bash script? drill shell_scripting
Front
How do you access command-line arguments in a bash script?
Back
$1, $2, $3, etc. for individual arguments $@ for all arguments $# for the number of arguments
What is the syntax for a for loop in bash? drill shell_scripting
Front
What is the syntax for a for loop in bash?
Back
for variable in list do # commands done
How do you define a function in bash? drill shell_scripting
Front
How do you define a function in bash?
Back
function_name() { # commands }
What command is used to read user input in bash? drill shell_scripting
Front
What command is used to read user input in bash?
Back
read variable_name
How do you perform arithmetic operations in bash? drill shell_scripting
Front
How do you perform arithmetic operations in bash?
Back
Using double parentheses: $((expression))
Example: result=$((5 + 3))
What is the purpose of the 'export' command in bash? drill shell_scripting
Front
What is the purpose of the 'export' command in bash?
Back
To make a variable available to child processes (subshells)
How do you redirect output to a file in bash? drill shell_scripting
Front
How do you redirect output to a file in bash?
Back
> : Overwrite the file
>> : Append to the file
Example: echo "Hello" > output.txt