Starting from:

$30

CSC3320- Systems Programming: Homework 2 Solved

Create a Google doc for each homework assignment submission.
Start your responses from page 2 of the document and copy these instructions on page 1.
Fill in your name, campus ID and panther # in the fields provided. If this information is missing in your document 
Each homework will typically have 2-3 PARTS, where each PART focuses on specific topic(s).
Start your responses to each PART on a new page.
If you are being asked to write code copy the code into a separate txt file and submit that as well.
If you are being asked to test code or run specific commands or scripts, provide the evidence of your outputs through a screenshot and copy the same into the document.
Upon completion, download a .PDF version of the document and submit the same.
Full Name:

Campus ID:

Panther #:

PART 1 
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 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.
What does the sort command do? What are the different possible fields? Explain using an example.
  Part IIa 
What is the output of the following sequence of bash commands: echo 'Hello World' | sed 's/$/!!!/g'
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 }

7.What is the output of the following command line: echo good | sed  '/Good/d'

Which awk script outputs all the lines where a plus sign + appears at the end of line?
9.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 
 Describe the function (5pts) and output (5pts) of the following commands.

$ 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

As the next command following question 9, $ awk  -f  awk  float
 
$ cat h2.awk

BEGIN { print "Start to scan file" } {print  $1 "," $NF}

         END {print      "END-" , FILENAME }

$ awk -f h2.awk float 12. sed  's/\s/\t/g'   float

 
$ ls *.awk| awk '{print "grep --color 'BEGIN' " $1 }' |sh (Notes: sh file runs file as a shell script . $1 should be the output of  ‘ ls *.awk ‘ in this case, not the 1st field )

 
        $ 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: 
Sort all the files in your class working directory (or your home directory) as per the following requirements:
A copy of each file in that folder must be made. Append the string
“_copy” to the name of the file

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).
The files in each directory must be sorted in chronological order of months.
An archive file (.tar) of each directory must be made. The .tar files must be sorted by name in ascending order.
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.

More products