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

UNIX -- Capture your session with the script utility and name it FinalActivity1.

ID: 3718268 • Letter: U

Question

UNIX --

Capture your session with the script utility and name it FinalActivity1. Upload the session recording FinalActivity1 as part of your response.

Create the directory structure UNX312/Activities/Activity1 in your home directory.

Using the cat command, create a file named classRoster with the following fields, separated by a comma.

Student ID

First Name

Last Name

Grade

Program of Study

SCHOOL ID (username)

Add three records to your file.

Display the contents of the file.

Move the file classRoster to the directory Activity1.

Go to the Activity1 directory.

Display the directory you are in.

Add read, write and execute permissions for user and group to Activity1 directory.

Create a new file called header using cat command with the following field names, separated by a tab.

Student ID

First Name

Last Name

Grade

Program of Study

STUDENT ID (username)

Display the file.

Copy the contents of header into classRoster, as the first line

Replace the comma with a tab using appropriate filters (such as cut, paste, tr, head, etc.)

Save this file as finalRoster.txt

Display the contents of the file finalRoster.txt

TIA

Explanation / Answer

NOTE: I have completed your assignment. Please check and let me know if you find any issues. I will revert back within 24 hours. thanks for your patience.

As the entire question is a sequence process, i thought of putting answers for each of the question asked. That way it would be easier to understand.

Step-Wise Explanation:

Q) Create the directory structure UNX312/Activities/Activity1 in your home directory.

Ans)

Unix Terminal> pwd

/Users/vishal

Unix Terminal> mkdir -p UNX312/Activities/Activity1

Unix Terminal>

1) The above command mkdir -p will create directories UNX312, Activities and Activity1 under home directory

2) The -p command in mkdir will enable mkdir command to create an entire directory structure.

Q) Using the cat command, create a file named classRoster with the following fields, separated by a comma.

Student ID

First Name

Last Name

Grade

Program of Study

SCHOOL ID (username)

Add three records to your file.

Ans)

Unix Terminal> cat > classRoster

123,Ronald,Arthur,A,CSC,ABC123

234,Herbet,Schildt,A+,CSI,ABC234

345,Galvin,Thomas,A-,CSB,ABC345

Unix Terminal>

1) The above cat > classRoster command will create a file classRoster. Then we have to type the three lines as above.

2) After that press ctrl+d to save the file with written contents.

Q) Display the contents of the file.

Ans)

Unix Terminal> cat classRoster

123,Ronald,Arthur,A,CSC,ABC123

234,Herbet,Schildt,A+,CSI,ABC234

345,Galvin,Thomas,A-,CSB,ABC345

Unix Terminal>

1) The command cat classRoster will display the contents of file classRoster

Q) Move the file classRoster to the directory Activity1.

Ans)

Unix Terminal> mv classRoster UNX312/Activities/Activity1

Unix Terminal>

1) The mv command will move classRoster file from your current directory to the directory UNX312/Activities/Activity1

Q) Go to the Activity1 directory.

Display the directory you are in.

Add read, write and execute permissions for user and group to Activity1 directory.

Ans)

Unix Terminal> cd UNX312/Activities/Activity1

Unix Terminal> ls -tlrh

total 8

-rw-r--r-- 1 vishal 1896053708 161B Apr 28 07:08 classRoster

Unix Terminal> cd ..

Unix Terminal> ls -tlrh

total 0

drwxr-xr-x 3 vishal 1896053708 102B Apr 28 07:09 Activity1

Unix Terminal> chmod ug+rwx Activity1/

Unix Terminal> ls -tlrh

total 0

1) The cd UNX312/Activities/Activity1 command will change to the directory UNX312/Activities/Activity1

2) ls -lthr command will display the contents of current directory

3) As we want to give read, write and execute permissions for user and group to Activity1 directory. We have to go back to one level up using cd .. command and provide permission

4) chmod ug+rwx Activity1/

will provide read, write and execute permission to the user(u) and group(g) to the directory Activity/

Q) Create a new file called header using cat command with the following field names, separated by a tab.

Student ID

First Name

Last Name

Grade

Program of Study

STUDENT ID (username)

Display the file.

Ans)

Unix Terminal> cat > header

Student ID First name Last name Grade Program of Study Student ID

Unix Terminal>

Unix Terminal> cat header

Student ID First name Last name Grade Program of Study Student ID

Unix Terminal>

1) The command cat > header will create the above mentioned field names each separated by tab. After that press ctrl+d to save the file contents.

2) cat header command will display the contents of file header

Q) Copy the contents of header into classRoster, as the first line

Ans)

Unix Terminal> cat header classRoster

Student ID First name Last name Grade Program of Study Student ID

123,Ronald,Arthur,A,CSC,ABC123

234,Herbet,Schildt,A+,CSI,ABC234

345,Galvin,Thomas,A-,CSB,ABC345

Unix Terminal> cat header classRoster > /tmp/class

Unix Terminal> cat /tmp/class

Student ID First name Last name Grade Program of Study Student ID

123,Ronald,Arthur,A,CSC,ABC123

234,Herbet,Schildt,A+,CSI,ABC234

345,Galvin,Thomas,A-,CSB,ABC345

Unix Terminal> mv /tmp/class classRoster

Unix Terminal>

1) In order to merge header and classRoster file contents we can use cat for concatenating two file. Like for instance,

cat header classRoster

will concatenate the contents of file header and classRoster. Since we want header line to the top of classRoster file thats why we have kept header file as the first filename to cat command.

2) cat header classRoster > /tmp/class

Will concatenate the contents of header and classRoster and redirect to /tmp/class file

3) mv /tmp/class classRoster

Will transfer or move the contents of /tmp/class to classRoster file

Q) Replace the comma with a tab using appropriate filters (such as cut, paste, tr, head, etc.)

Save this file as finalRoster.txt

Display the contents of the file finalRoster.txt

Ans)

Unix Terminal> cat classRoster

Student ID First name Last name Grade Program of Study Student ID

123,Ronald,Arthur,A,CSC,ABC123

234,Herbet,Schildt,A+,CSI,ABC234

345,Galvin,Thomas,A-,CSB,ABC345

Unix Terminal>

Unix Terminal> cat classRoster |tr -s ' ' ',' > finalRoster.txt

Unix Terminal> cat finalRoster.txt

Student ID,First name,Last name,Grade,Program of Study,Student ID

123,Ronald,Arthur,A,CSC,ABC123

234,Herbet,Schildt,A+,CSI,ABC234

345,Galvin,Thomas,A-,CSB,ABC345

Unix Terminal>

1) cat classRoster

will dipslay the contents of file classRoster

2) tr -s ' ' ','

will replace all tab characters with ,

3) cat classRoster |tr -s ' ' ',' > finalRoster.txt

replaces all occurences of tab characterw with command and save to file finalRoster.txt

4) cat finalRoster.txt

displays the contents of file