Systems Programming Homework

$24.99 $18.99

PART 1 (2.5 points each): 10pts What are the differences among ​grep​, ​egrep​and ​fgrep​? Describe using an example. Which utility can be used to compress and decompress files? And how to compress multiple files into a single file? Please provide one example for it. Which utility (or utilities) can break a line into multiple fields…

5/5 – (2 votes)

You’ll get a: zip file solution

 

Description

5/5 – (2 votes)

PART 1 (2.5 points each): 10pts

  1. What are the differences amonggrep,egrepandfgrep? Describe using an example.

  1. Which utility can be used to compress and decompress files? And how to compress multiple files into a single file? Please provide one example for it.

  1. Which utility (or utilities) can break a line into multiple fields by defining a separator? What is the default separator? How to define a separator manually in the command line? Please provide one example for defining the separator for each utility.

  1. What does thesort command do? What are the different possible fields? Explain using an example.

​​Part IIa (5 points each): 25pts

  1. What is the output of the following sequence of bash commands:echo ‘Hello World’ | sed ‘s/$/!!!/g’

  1. What is the output for each of these awk script commands?

    • 1 <= NF { print $5 }

    • NR >= 1 && NR >= 5 { print $1 }

    • 1,5 { print $0 }

    • {print $1 }

  1. What is the output of following command line:

echo good | sed ‘/Good/d’

  1. Whichawkscript outputs all the lines where a plus sign + appears at the end of line?

  1. What is the command to delete only the first 5 lines in a file “foo”? Which command deletes only the last 5 lines?

Part IIb (10pts each): 50pts

Describe the function (5pts) and output (5pts) of the following commands.

9. $ cat float

Wish I was floating in blue across the sky, my imagination is strong, And I often visit the days

When everything seemed so clear.

Now I wonder what I’m doing here at all…

  • cat h1.awk

NR>2 && NR<4{print NR “:” $0

$ awk ‘/.*ing/ {print NR “:” $1}’ float

  1. As the next command following question 9, $ awk -f h1.awk float

11.

$cat h2.awk

BEGIN { print

“Start to scan file” }

{print $1 “,” $NF}

END {print “END-” , FILENAME }

    • awk -f h2.awk float

  1. sed ‘s/\s/\t/g’ float

13.

  • ls *.awk| awk ‘{print “grep –color ‘BEGIN’ ” $1 }’ |sh(Notes:sh fileruns file as a shell script . $1 should be the output of ‘ls *.awk ‘ in this case, not the 1st field)

14.

  • mkdir test test/test1 test/test2 $cat>test/testt.txt

This is a test file ^D

  • cd test

  • ls -l.| grep ‘^d’ | awk ‘{print “cp -r ” $NF ” ” $NF “.bak”}’ | sh

Part III Programming: 15pts

  1. Sort all the files in your class working directory (or your home directory) as per the following requirements:

    1. A copy of each file in that folder must be made. Append the string “_copy” to the name of the file

    1. The duplicate (copied) files must be in separate directories with each directory specifying the type of the file (e.g. txt files in directory named txtfiles, pdf files in directory named pdffiles etc).

    1. The files in each directory must be sorted in chronological order of months.

    1. An archive file (.tar) of each directory must be made. The .tar files must be sorted by name in ascending order.

    1. An archive file of all the .tar archive files must be made and be available in your home directory.

As an output, show your screen shots for each step or a single screenshot that will cover the outputs from all the steps.

Systems Programming Homework
$24.99 $18.99