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

Linux There exists a command named tee . It takes as input the data that you wan

ID: 3843604 • Letter: L

Question

Linux

There exists a command named tee. It takes as input the data that you want to redirect (for example through a pipe), and its arguments are all the files where you want to redirect it. That way, it is possible to redirect data to multiple files within one line. The solutions you saw took 51 and 22 lines. Using mkdir -p and tee, write a script that does it in at most 15 lines. Any solution with more lines will not be counted.

#create CSCI330 directory

mkdir ./CSCI330

#create lectures directory and content

mkdir ./CSCI330/lectures

mkdir -p ./CSCI330/lectures/1

mkdir -p ./CSCI330/lectures/2

lorem -p 3 > ./CSCI330/lectures/1/1-a

lorem -p 3 > ./CSCI330/lectures/1/1-b

lorem -p 3 > ./CSCI330/lectures/1/1-c

lorem -p 3 > ./CSCI330/lectures/2/2-a

#creates the assign directory and all of its sub-content

mkdir ./CSCI330/assign

mkdir -p ./CSCI330/assign/mine ./CSCI330/assign/cheating

mkdir -p ./CSCI330/assign/mine/1 ./CSCI330/assign/mine/2

mkdir -p ./CSCI330/assign/cheating/1 ./CSCI330/assign/cheating/2

lorem -p 3 > ./CSCI330/assign/mine/1/ques

lorem -p 3 > ./CSCI330/assign/mine/1/ans

lorem -p 3 > ./CSCI330/assign/mine/2/ques

lorem -p 3 > ./CSCI330/assign/mine/2/ans

lorem -p 3 > ./CSCI330/assign/cheating/1/jeff

lorem -p 3 > ./CSCI330/assign/cheating/1/dan

lorem -p 3 > ./CSCI330/assign/cheating/2/bob

#creates stuff directory and content

mkdir ./CSCI330/stuff

lorem -p 3 > ./CSCI330/stuff/linuxjokes

Explanation / Answer

# Follwing is the shell script for given problem.This script make use of mkdir -p and tee command to redirect the user entered content to all mentioned files.

#create CSCI330 directory

mkdir ./CSCI330
#create lectures directory and content
mkdir ./CSCI330/lectures
mkdir -p ./CSCI330/lectures/1
mkdir -p ./CSCI330/lectures/2
#creates the assign directory and all of its sub-content
mkdir ./CSCI330/assign
mkdir -p ./CSCI330/assign/mine ./CSCI330/assign/cheating
mkdir -p ./CSCI330/assign/mine/1 ./CSCI330/assign/mine/2
mkdir -p ./CSCI330/assign/cheating/1 ./CSCI330/assign/cheating/2
#creates stuff directory and content
mkdir ./CSCI330/stuff

tee ./CSCI330/lectures/1/1-a ./CSCI330/lectures/1/1-b ./CSCI330/lectures/1/1-c ./CSCI330/lectures/2/2-a ./CSCI330/assign/mine/1/ques ./CSCI330/assign/mine/1/ans

./CSCI330/assign/mine/2/ques ./CSCI330/assign/mine/2/ans ./CSCI330/assign/cheating/1/jeff ./CSCI330/assign/cheating/1/dan ./CSCI330/assign/cheating/2/bob ./CSCI330/stuff/linuxjokes

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