Operating Systems Concepts & Design
You can use a command in support of your answer, but we are evaluating your written response.
./check with no arguments and gets [: -gt: unary operator expected. Why?
#!/bin/bash
if [ $1 -gt 1 ]; then
echo "Valid"
fi
./compare. It prints 3 is greater than 10, and ls now shows a new file named 10 in the directory. Why?
#!/bin/bash
num=3
if [ "$num" > 10 ]; then
echo "$num is greater than 10"
fi
0 at the prompt and the script prints Must be greater than 1 forever. What is the bug?
read -p "Sides: " sides
while [ "$sides" -le 1 ]; do
echo "Must be greater than 1"
done
./tasks "Buy milk" "Walk dog", and why?
for task in $@; do
echo "$task"
done
./dotinstall -a -h and sees Adding: -h, but the user guide never displays. Why?
while getopts "ha:r:" opt; do
case $opt in
h) user_guide ;;
a) echo "Adding: $OPTARG" ;;
r) echo "Removing: $OPTARG" ;;
esac
done
A script uses while getopts "v" opt to handle a -v flag, then runs echo "File: $1" after the loop. A user runs ./script -v notes.txt and sees File: -v. Why, and what is one way to fix it?
nums.txt, which lines will grep "[^0-9]" nums.txt output, and why?
42
3.14
-5
100
A student runs grep "3.14" values.txt and the output includes the line 3014. Why?
emails.txt, only bob@gmail.com is output by grep -E "^[a-z]+@[a-z]+\.com$" emails.txt. Why did each of the other lines not match?
kay@wright.edu
bob@gmail.com
Sally@gmail.com
dana@mail.gmail.com
sed: -e expression #1, char 9: unknown option to 's'. Why, and what is one way to fix it?
sed 's//home/ubuntu//home/kay/g' config.txt
remove action in tt runs the line below, but the task is never deleted from .tasks, even though $task holds a description that is in the file. Why?
sed -i '/$task/d' "$HOME/.tasks"
sales.txt, why does awk '{print $2}' sales.txt print only blank lines?
2024-01-15,Laptop,Electronics,3,899.99,2699.97
2024-02-03,Blender,Kitchen,5,49.99,249.95