Give the command (single command or pipelined series of commands) that performs
ID: 3777473 • Letter: G
Question
Give the command (single command or pipelined series of commands) that performs each of the following tasks. Assume bash. Do not use things like perl, awk, python, etc. Unless specifically stated otherwise, assume that the command should work no matter what your current working directory is or where a user's home directory is located. Use only flags that are required by the question as stated. Assume you are logged in as a "normal" (non-administrator) user, but that you have "administrative" permissions set up in the sudoers file in case you would be required to take advantage of that in order to carry out any of these tasks. Use only single spaces between parts of a command/options/arguments, and do not put extra spaces before or after the answers.
a) Lists all the files and/or directories in the directory one level above the current working directory that have names that start with “a” or “b”. (Tried ls .. [ab]* and ls ../[ab]* does not work)
b) Copies user turk’s Networking directory, all its files, all its subdirectories, and all files in all its subdirectories, preserving all file permissions, to the ~/MyNetworking directory. Assume permissions are set on turk's NetworkingClass directory to allow you to do this. (Tried cp -r -p /Networking ~/MyNetworking not sure if it worked or not)
Explanation / Answer
Solution:
Command the performs the operation is :
//user needs to enter the name of the directory.
echo "enter the directory name"
//read is a keyword which reads the directory
read dir
//copies the files from the directory to the subdirectory
cp origfile /directory/subdirectory
if [ -d $dir ]
then
cd $dir
ls > f
exec < f
while read line
do
//If condition to print the list in the diectory after checking the condition
if [ -f $line ]
then
if [ -r $line -a -w $line -a -x $line ]
then
echo "$line has all permissions"
else
echo "files not having all permissions"
fi
fi
done
fi
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.