When the script below is run as ./myscript.sh repdat.txt, what will be output to the terminal?Note: Be precise in your answer. It must be exactly what would appear in the terminal#!/bin/bashcat $1 | grep -v "^[0-9]\{2\}%" | wc -lexit 0NOTE: The repdat.txt file contains the following lines:Breach data for the report was compiled in March and April 2020 by an independent research company.Key survey findings from respondents were as follows:94% said attack volume has increased in the last 12 months, the survey found.96% said their business has suffered a security breach in the last 12 months.The average organization said they experienced 2 breaches during that time, the survey found.88% said attacks have become more sophisticated.96% said they plan to increase cyber defence spending in the coming year.OS vulnerabilities and third-party application attacks were the leading cause of breachesCompanies said they are using an average of 7 different breach prevention technologies.
Question
When the script below is run as ./myscript.sh repdat.txt, what will be output to the terminal?Note: Be precise in your answer. It must be exactly what would appear in the terminal#!/bin/bashcat $1 | grep -v "^[0-9]{2}%" | wc -lexit 0NOTE: The repdat.txt file contains the following lines:Breach data for the report was compiled in March and April 2020 by an independent research company.Key survey findings from respondents were as follows:94% said attack volume has increased in the last 12 months, the survey found.96% said their business has suffered a security breach in the last 12 months.The average organization said they experienced 2 breaches during that time, the survey found.88% said attacks have become more sophisticated.96% said they plan to increase cyber defence spending in the coming year.OS vulnerabilities and third-party application attacks were the leading cause of breachesCompanies said they are using an average of 7 different breach prevention technologies.
Solution
The script provided is a bash shell script. When run with the argument repdat.txt, it will perform the following operations:
-
cat $1: This command will output the contents of the filerepdat.txtto the terminal. The$1is a special variable in bash that refers to the first argument passed to the script, in this caserepdat.txt. -
grep -v "^[0-9]\{2\}%": This command will filter out any lines from thecatcommand's output that start with two digits followed by a percent sign. The-voption inverts the match, so it removes lines that match the pattern instead of keeping them. -
wc -l: This command will count the number of lines in the output from thegrepcommand.
So, the script will output the number of lines in repdat.txt that do not start with two digits followed by a percent sign.
Given the content of repdat.txt, the lines that start with two digits followed by a percent sign are:
94% said attack volume has increased in the last 12 months, the survey found.
96% said their business has suffered a security breach in the last 12 months.
88% said attacks have become more sophisticated.
96% said they plan to increase cyber defence spending in the coming year.
So, these 4 lines will be removed by the grep command. The remaining lines are:
Breach data for the report was compiled in March and April 2020 by an independent research company.
Key survey findings from respondents were as follows:
The average organization said they experienced 2 breaches during that time, the survey found.
OS vulnerabilities and third-party application attacks were the leading cause of breaches
Companies said they are using an average of 7 different breach prevention technologies.
So, the script will output 5, which is the number of these remaining lines.
Similar Questions
When the script below is run as ./myscript.sh repdat.txt, what will be output to the terminal?Note: Be precise in your answer. It must be exactly what would appear in the terminal#!/bin/bashcat $1 | grep -v "^[0-9]\{2\}%" | wc -lexit 0NOTE: The repdat.txt file contains the following lines:Breach data for the report was compiled in March and April 2020 by an independent research company.Key survey findings from respondents were as follows:94% said attack volume has increased in the last 12 months, the survey found.96% said their business has suffered a security breach in the last 12 months.The average organization said they experienced 2 breaches during that time, the survey found.88% said attacks have become more sophisticated.96% said they plan to increase cyber defence spending in the coming year.OS vulnerabilities and third-party application attacks were the leading cause of breachesCompanies said they are using an average of 7 different breach prevention technologies.
If I run the command ./scriptname.sh parameters 5 5 with the code below, what will the output to terminal be?Note: You response must be precisely what will be printed to the terminal to be marked correct.#!/bin/bashecho $(expr substr "$1" "$2" "$3")exit 0
When the script below is run as ./myscript.sh -d 10,6 what will the output to terminal be?#!/bin/bashOPTERR="Invalid option"declare -a argsIFS=','if [[ $# -gt 0 ]]; thenwhile getopts "a:s:d:m:" opt; do for arg in $OPTARG; do args+=("$arg") done case $opt in a) echo $( expr ${args[0]} + ${args[1]} );; s) echo $( expr ${args[0]} - ${args[1]} );; d) echo $( expr ${args[0]} / ${args[1]} );; m) echo $( expr ${args[0]} \* ${args[1]} );; *) echo "$OPTERR" && exit 1;; esac donefiIFS=" "exit 0
QUESTION: When the code below is run, what will be output to the terminal?#!/bin/bashstr='Book Title 1: <em>Think and Grow Rich</em> by Napoleon Hill'echo $str | sed 's/.*>.∗<.*/\1/'exit 0Group of answer choices<em></em>hink and Grow Ricby Napoleon HillThink and Grow Rich
What is the purpose of the script command in Kali Linux?Question 17Answera.To execute a script fileb.To display the contents of a script filec.To create a script filed.To record all the terminal output, including all typed commands and their output, to a file
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.