FlashKeepers

Linux · CompTIA Linux+ · Professional Certifications

Linux Shell Scripting Basics

Basic bash shell scripting concepts including variables, loops, and conditionals.

About this set

40 basic cards for CompTIA Linux+ Linux. It opens with "How do you declare and assign a variable in bash?" and "What is the syntax to reference a variable's value in bash?". More Professional Certifications decks are listed below.

40 cards · basic cards · AI-written, checked twice. Edit anything.

Study this set free Look inside first Get FlashKeepers for iPhone

Opens in your browser, no account. Get the iPhone and iPad app · Android app

How do you declare and assign a variable in bash?
Show answerVARIABLE_NAME=value (no spaces around the equals sign)
What is the syntax to reference a variable's value in bash?
Show answer$VARIABLE_NAME or ${VARIABLE_NAME}
What command exports a variable so it is available to child processes?
Show answerexport VARIABLE_NAME
How do you assign the result of a command to a variable?
Show answerVARIABLE=$(command) or VARIABLE=`command`
What is the difference between single quotes and double quotes in bash?
Show answerDouble quotes allow variable expansion and command substitution; single quotes treat everything literally
What does the read command do in a bash script?
Show answerReads input from the user and stores it in a variable
What is the basic structure of an if statement in bash?
Show answerif [ condition ]; then commands; fi
How do you test if a file exists in an if statement?
Show answerif [ -f /path/to/file ]; then
How do you test if a directory exists in an if statement?
Show answerif [ -d /path/to/directory ]; then
What does the -z flag test for in a condition?
Show answerTests if a string is empty (zero length)
What does the -n flag test for in a condition?
Show answerTests if a string is not empty (has length)
How do you compare two numbers in an if statement?
Show answerUse -eq, -ne, -lt, -le, -gt, or -ge inside brackets
What is the syntax for an if-else statement in bash?
Show answerif [ condition ]; then commands; else commands; fi
What is the syntax for an if-elif-else statement in bash?
Show answerif [ condition1 ]; then commands; elif [ condition2 ]; then commands; else commands; fi
What is the basic structure of a for loop in bash?
Show answerfor variable in list; do commands; done

25 more cards in the app

Study this set free