Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Unix shell utillities 3 UNIX Shell Utilities[30 pts] 1. Given sed -n \'10,$p\' i

ID: 3708706 • Letter: U

Question

Unix shell utillities

3 UNIX Shell Utilities[30 pts] 1. Given sed -n '10,$p' inputlsed '/cat/s/dog/fly/', what does this command do? |3 pts] 2. Print only the 17th line of a given file using head and tail commands. [3 pts] 3. Create a directory under your home directory, and add this directory to your SPATH variable. Verify it by printing the value of SPATH variable, and running an executable placed under this directory from your home directory. Briefly explain why adding this new directory to the SPATH variable is useful. [4 pts] 4. Write a command to display only the files under a directory(But not directories and others). [4 pts 5. Cron is a job scheduling utility provided by Linux/Unix systems, and it allows for periodical execution of predefined commands. Cron jobs are defined using crontab files(You can read more about crontab files here http://www.adminschoice.com/crontab-quick-reference). Write a crontab line that creates an empty file named update.txt under the home directory at 6:32PM of every 7th, 14th, 21st and 28th days of every month. [4 pts 6. i) Create an A4tmp directory in your home directory. ii) Read the man page for the find command. Find out all files (only files) within or below the /var/log directory that have a file size greater than 2000 bytes, while directing all stderr messages to a file called logerror.txt in the A4tmp directory in your home directory. 4 pts 7. i) How many entries with .gz extension are there in the /usr/share/man/manl directory? ii) Within them, how many are not symbolic links? Note that in the output of ls -1, a symbolic link has letter 1 at the start of its line, it also has a "sign in its line. [4 pts 8. i) How many words, lines and characters are there in /usr/share/dict/words respectively? ii) Based on the result in i), how many words are there on each line of the file? iii) Save the words between 100-200 and 400-600 (both inclusive) in this file to files named 100-200.txt and 400-600.txt in your /A4tmp directory, respectively. [4 pts]

Explanation / Answer


1) The sed command in right part will replace all the dogs with fly and display the result on the console. The first sed command then print the 10 lines from the previous result.

2) This command will first count the number of lines and then subtract this with the 17 lines giving argument to tail command.
head -n 17 file | tail -n | wc -l -17

3) Creating a new directory and adding that directory to the $PATH variable. Once the directory is added it needs to be Sourced.
mkdir newDir
export PATH=$PATH:/home/newDir
source ~/.bashrc

4) This will print only the files in the current directory. The hidden files remain included in result.
ls -pa | grep -v /

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote