Bash

This page displays an accessible version of a Quizlet meant for the use of blind or visually impaired people. The original version of the Quizlet can be found here [original version].

You can make more Quizlets accessible on the homepage of this website.

Term Definition
function sumitup { echo $(($1 + $2)) ; } Which of the following commands creates a function in Bash that outputs the sum of two numbers? function sumitup { echo $(($1 + $2)) ; } method sumitup { echo $1 + $2 ; } function sumitup { echo $1 + $2 ; } command sumitup { echo $(($1 + $2)) ; } command sumitup { echo $1 + $2 ; }
1 What is the result student@lintro~$a=5 student@lintro~$b=6 student@lintro~$[ a -gt b] student@lintro~$ echo $? 0 1 True False
It is the exit value of the command executed immediately before echo. When the command echo $? outputs 1, which of the following statements are true? It is the exit value of the command executed immediately before echo. It is the process ID of the current shell. It is the process ID of the echo command. It is the exit value of the echo command.
| uniq -c A user needs to count the different permission types. The command so far looks like: ls -l| cut -c1-10|sort What needs to be added to the end to count the different permission types: | wc -w | uniq -c | wc -c | wc -l
# A comment line in a script begins with
Usage: ./single start|stop Here is the bash code for the single master script: What will happen if I type the command: ./single Error: argument '$1' not supported Syntax error on line 5 Usage: ./single start|stop The computer will go into single mode
env Which command allows me to see all the preloaded bash variables? showvar grep preload env
Your name is $name What will be the output on the screen when the following lines are run: name='Jane' echo 'Your name is $name' Your name is Syntax error Your name is Jane Your name is $name
~/.bash_profile ~/.bashrc Which of the following files, when existing, affect the behavior of the Bash shell? ~/.bashconf ~/.bash_etc ~/.bashdefaults ~/.bash_profile ~/.bashrc
PATH=$PATH:~ A student complains that the script won't run. How would you fix this error? student@debian:~$ guess.shbash: guess.sh: command not found PATH=$PATH:~ This error can not be fixed by student There is not enough information to answer this question chmod 777 guess.sh
Loop 1 Loop 2 Loop 3 What will be the output from the following bash code: for i in 1 2 3 do #start the loop echo "Loop $i" done # end the loop Syntax error in line 2 Undefined command Loop Loop 1 Loop 2 Loop 3 Loop 1 Loop 2
HISTFILE Which Bash environment variable defines in which file the user history is stored when exiting a Bash process?
Hll Wrld What is the output of the following command? echo "Hello World" | tr -d aieou Hll Wrld eoo Hello World eoo Hll Wrld
foo bar When given the following command line. echo "foo bar" | tee bar | cat Which of the following output is created? tee bar foo cat bar foo bar
echo $? echo "Usage: $0 start|stop" >&2 exit 3 Given the above script how would I see what the error message number was?
Match the preceding qualifier zero or one times. What does the ? symbol within regular expressions represent? Match the preceding qualifier zero or more times. Match a literal ? character. Match the preceding qualifier zero or one times. Match the preceding qualifier one or more times
ls -a What command would produce this output? . .gksu.lock .pulse.. .gnome2 .pulse-cookie.bash_history .gnome2_private secret.bash_logout .gstreamer-0.10 Templates.bashrc .gtk-bookmarks testbin .gvfs The secret voice in your head.mp3.cache .ICEauthority .thumbnails.config .local varlogoutfile.txt.dbus .mission-control VideosDesktop .mozilla vmware-tools-distribDocuments Music .xsession-errorsDownloads Pictures .xsession-errors.old.fontconfig .profile cd -l ls -a ls -l cd -a
Convert the text language into a machine code before running it. What does it mean to compile a language? Convert the text language into a machine code before running it. Place it into a dictionary build it from the ground up Put it together from scratch
This is a leap year, February has 29 days. if [ $[$year % 400] -eq "0" ]; then echo "This is a 400 leap year. February has 29 days." elif [ $[$year % 4] -eq 0 ]; then if [ $[$year % 100] -ne 0 ]; then echo "This is a leap year, February has 29 days." else echo "This is not a leap year. 100th year so skip. February has 28 days." fi else echo "This is not a leap year. February has 28 days." fi What would result if year=2004? This is a leap year, February has 29 days. This is a 400 leap year, February has 29 days. "This is not a leap year. 100th year so skip. February has 28 days." This is not a leap year. February has 28 days.
This shell script executes the logrotate command writing errors to syslog What does the following script do? #!/bin/sh /usr/sbin/logrotate /etc/logrotate.conf EXITVALUE=$? if [ $EXITVALUE != 0 ]; then /usr/bin/logger -t logrotate "ALERT exited abnormally with [$EXITVALUE]" fi exit 0 This shell script changes the logrotate configuration files This shell script crashes with an error message This shell script executes the logger and logrotate commands each time it is run. This shell script executes the logrotate command writing errors to syslog
[ $x -lt $y ] Assume that two variables named x and y have numeric values. Which of the following is the correct way to compare whether the value of x is less than y? [ $x -lt $y ] [ $x -lessthan $y ] [ $x < $y ] [ $x > $y ]
file1.xml file1.xml.bak file2.xml file2.xml.bak file3.xml file3.xml.bak What output would appear after this code is run? student@lintro~$ ls *.xmlfile1.xml file2.xml file3.xmlstudent@lintro~$ ls *.xml > liststudent@lintro~$ for i in `cat list`; do cp "$i" "$i".bak ; donestudent@lintro~$ ls *.xml* file1.xml file2.xml file3.xml file1.xml file1.xml.bak file2.xml file2.xml.bak file3.xml file3.xml.bak file1.bak file2.bak file3.bak file1.bak file1.bak.bak file2.bak file2.bak.bak file3.bak file3.bak.bak
There is no rule Every line in a shell script ends with ; > There is no rule :
no match If I have the following program: a=5 b=6 if [ "$a" -ne "$b" ] then echo no match fi What will appear on the screen? no match permission denied error syntax error nothing
bash What is the default shell in linux for normal users? csh bash usershell powershell
5 If I have the following script: #!/bin/bash x=1 while [ $x -le 5 ] do echo "Welcome $x times" x=$(( $x + 1 )) done How many times will I be welcomed 5 3 1 6
It tells the shell what program should run the script What is the "shebang" used for at the beginning of a script? It compiles the script so it can be executed It tells the shell what program should run the script It indicates if the script should be run as root It sets permissions for script execution
source /usr/local/bin/runme.sh . /usr/local/bin/runme.sh From a Bash shell, which of the following commands directly executes the instruction from the file /usr/ local/bin/runme.sh without starting a subshell? (Please select TWO answers.) run /usr/local/bin/runme.sh /usr/local/bin/runme.sh . /usr/local/bin/runme.sh source /usr/local/bin/runme.sh /bin/bash /usr/local/bin/runme.sh
test [ is eqvivalent to
result: 3 4 5 6 2 1 What output will the following command sequence produce? echo '1 2 3 4 5 6' | while read a b c; do echo result: $c $b $a; done result: 6 5 4 result: 3 2 1 result: 3 4 5 6 2 1 result: 1 2 3 4 5 6 result: 6 5 4 3 2 1
Green Given the following bash script: until [ "$Answer" = "Green" ] do echo "What is your favorite color?" read Answer done What text must be entered to exit the loop?
read How do I get a response back from the keyboard capture getch read get
Error: argument 'reload' not supported Here is the bash code for the single master script: What will happen if I type the command: ./single reload syntax error in script single on line 5 Usage: ./single start|stop Error: argument 'reload' not supported Error: argument '$1' not supported
generate a number between 1 and 10 What will the following command do? echo $[1+ $[ RANDOM %10]] generate a number between 0 and 9 syntax error permission denied error generate a number between 1 and 10
Numbers The comparison operator " -eq " is used for Numbers Strings Characters Any kind of data
cut -d : -f 1,4 /etc/passwd Which of the following commands prints a list of usernames (first column) and their primary group (fourth column) from the /etc/passwd file? paste -f 1,4 /etc/passwd cut -d : -f 1,4 /etc/passwd fmt -f 1,4 /etc/passwd split -c 1,4 /etc/passwd
fi What word will complete an if statement in bash such as the following: if [ -x "$file" ]; then echo $file _____ (Please provide the missing word only)
$ Which of the following symbols is used as prefix to access the value of variables in scripting
Any one character ". " is used to match Any number of characters Only " . " Only special characters Any one character
chmod Scripts are made executable using the command
chooses the bash interpreter What does the shebang #!/bin/bash do?
myls="$(ls)", myls=`ls` Which of the following commands puts the output of the command ls into the shell variable myls? (CHOOSE 2) myls="${ls}" myls="ls" myls="$(ls)" myls="exec ls" myls='$(ls)' myls=`ls`
Echo adds a new line after printing, printf does not The difference between printf and echo is They are completely different Both are same printf adds a new line after printing, echo does not Echo adds a new line after printing, printf does not
chmod +x guessgame I try to run my script but I get the error: student@debian:~/Documents$ ./guessgamebash: ./guessgame: Permission denied What do I need to do to fix it? give up it won't run change permission guessgame chmod +x guessgame log in as super user with more permissions
echo `ls` Which of these commands will give me the directory listed with no newlines? echo 'ls' echo `ls` echo ls echo "ls"
dsh Which of the following is not a kind of shell? ksh csh bash dsh
export VARIABLE Which command makes the shell variable named VARIABLE visible to subshells? set $VARIABLE export $VARIABLE export VARIABLE env VARIABLE set VARIABLE
25 Given the above output for the df command what will the following line do? df -h | awk '{print $5}' | grep % | grep -v Use | sort -n | tail -1 | cut -d "%" -f1 636 19 581 25