Docsity

Bash Scripting Exercises and Solutions, Exams of Advanced Education

Toggle sidebar
bg1
14.1.5 Bash Shell Scripting latest update solution
Which of the following are valid ways to assign a variable a value in a
bash script? (Select two.) - declare -i num1=4
variable1=Hello
You have created the following Bash script:
#!/bin/bashdeclare -i num1declare -i num2declare -i
totalnum1=10num2=2total=num1-num2echo $totalexit 0
What will be displayed on the screen after running the script? - 8
Which of the following commands in a Bash script will display "Farewell,
Jason" on the screen? - variable2=Farewellecho $variable2 ", Jason"
Which of the following commands do you need to enter to end a Bash
shell script? - exit 0
Troy, a system administrator, created a script to automate some daily
administrative tasks.
Which of the following commands would make Troy's script,
/scripts/dailytasks, executable by everyone but writable only by its owner?
- chmod u=rwx,go=rx /scripts/dailytasks
Which of the following commands creates a variable and prompts the user
to type in text? - read
What would you enter at the command prompt to run a listdocs script
stored in the current directory? - ./listdocs
pf2

Partial preview of the text

Download Bash Scripting Exercises and Solutions and more Exams Advanced Education in PDF only on Docsity!

14.1.5 Bash Shell Scripting latest update solution Which of the following are valid ways to assign a variable a value in a bash script? (Select two.) - declare -i num1= variable1=Hello You have created the following Bash script: #!/bin/bashdeclare -i num1declare -i num2declare -i totalnum1=10num2=2total=num1-num2echo $totalexit 0 What will be displayed on the screen after running the script? - 8 Which of the following commands in a Bash script will display "Farewell, Jason" on the screen? - variable2=Farewellecho $variable2 ", Jason" Which of the following commands do you need to enter to end a Bash shell script? - exit 0 Troy, a system administrator, created a script to automate some daily administrative tasks. Which of the following commands would make Troy's script, /scripts/dailytasks, executable by everyone but writable only by its owner?

  • chmod u=rwx,go=rx /scripts/dailytasks Which of the following commands creates a variable and prompts the user to type in text? - read What would you enter at the command prompt to run a listdocs script stored in the current directory? - ./listdocs

Which of the following shell declarations should you enter on the first line of a script for a system that uses the Bash shell? - #!/bin/bash You can use the time command to determine how long a given command takes to run. The output of the time command displays three values. Which of the following are the time values displayed by the time command? (Select three.) - system user real When creating a Bash script, it is important to document the purpose of the script. Which of the following is a valid comment? - # This is a Bash script