Shell Scripting Advanced – Full Quiz
← Back to Quiz Home
This quiz contains 20 questions focused on Functions, regex, text processing, and advanced automation .
These skills are required for building complex DevOps tools.
How do you define a function in Bash?
The standard syntax is func_name() { commands; }. Sometimes the function keyword is used: function func_name { commands; }.
How do you pass arguments to a function?
Arguments are passed separated by spaces, just like command-line arguments.
How do you access the first argument inside a function?
$1, $2, etc., refer to the positional parameters passed to the function.
How do you return an integer value from a function?
The return statement returns an exit status (0-255). To return data (strings), using echo is common.
Which command prints one column from a text file?
awk is powerful for column-based processing. cut can also be used but uses slightly different syntax.
How do you replace "foo" with "bar" in a file using strict substitution?
sed 's/old/new/g' is the standard stream editor command for usage.
How do you find lines matching a pattern in a specific file?
grep searches for patterns in files.
How do you run a command in the background?
Appending & to a command runs it in the background.
Which command keeps a process running after you log out?
nohup (no hang up) runs a command immune to hangups, with output to a non-tty.
How do you schedule a script to run every minute?
crontab is the standard daemon for scheduling periodic tasks.
It redirects file descriptor 2 (stderr) to file descriptor 1 (stdout).
How do you debug a script line-by-line?
bash -x prints commands and their arguments as they are executed.
Which command allows you to parse JSON?
jq is a lightweight and flexible command-line JSON processor.
How do you create a temporary file securely?
mktemp creates a temporary file or directory with a unique name.
What is the purpose of xargs?
xargs reads items from standard input and executes a command with them as arguments.
How do you declare a local variable in a function?
The local keyword makes the variable visible only within the function block.
Which regex character matches the start of a line?
^ matches the beginning of a line. $ matches the end.
Which tool is best for checking if a port is open?
nc (netcat) is widely used for reading from and writing to network connections using TCP or UDP.
How do you check the exit status of the usage of grep if no match is found?
grep returns 0 if a match is found, and 1 if no match is found.
How can you process command-line arguments using a loop?
"$@" expands to all command-line arguments as separate words.
Quiz Progress
0 / 0 questions answered
(0% )
0 correct
Quiz Complete!
0%
Reset quiz
📚 Study Guides
📬 Weekly DevOps, Cloud & Gen AI quizzes & guides