UNIX/LINUX QUESTIONS. Please solutions only. Thanks! 1. In Linux, the PATH (Sobe
ID: 3701628 • Letter: U
Question
UNIX/LINUX QUESTIONS. Please solutions only. Thanks!
1. In Linux, the PATH (Sobell, page 308) keyword variable specifies the directories in the order bash should search them when it searches for a script or program you run from the command line. In BASH, what would be the value of your PATH variable? What happens when you put the statement echo $PATH in the BASH function created in previous question.
2. What will the BASH script below do when it runs? Try to describe each line of the code shown below in simple or plain English to demonstrate your understanding of the code.
#!/bin/bash
question15()
{
arg1=$1
arg2=$2
ls
if [ $# -gt 0 ]; then
clear
if [[ -f $1 && -w $1 ]]; then
echo The file $1 is readable
cp $1 $2.bak
echo The backup file created f $2.bak is a copy of $1 file.
else
echo The file $1 does not exist or is not writable file
fi
fi
}
question15 hello hello
3. Develop simple HTML page that creates a web interface for the BASH script above (question 2)
Explanation / Answer
Answer 1: The value of the PATH will be: /usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/user_name/bin.
Answer 2: Two arguments are taken .
Then list using ls
If the number of command line arguments(#$) is greater than 0
if both the conditions satisfied, then print file is readable and one copy of 2 is made as a backup file of 1.
else print either file 1 does not exist or not writable.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.