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

Write a sed script that works as below. It takes the name of a data file via inp

ID: 3825019 • Letter: W

Question

Write a sed script that works as below.

It takes the name of a data file via input redirection. The file used for redirection is the output of the command

ls –l | tail –n +2 >lsfile

Here is a sample content of the file.

-rw-r--r-- 1 cfs264sp170225 cfs264sp1702   21 2017-04-16 d1

drwxr-xr-x 2 cfs264sp170225 cfs264sp1702 4096 2017-04-16 dir1

-rw-r--r-- 1 cfs264sp170225 cfs264sp1702 181 2017-04-16 lsfile

-rwxr-xr-x 1 cfs264sp170225 cfs264sp1702 179 2017-04-16 p1

-rwxr-xr-x 1 cfs264sp170225 cfs264sp1702   14 2017-04-16 p2

-r--r-xr-x 1 cfs264sp170225 cfs264sp1702 828 2017-04-16 signindata

-rw-r--r-- 1 cfs264sp170225 cfs264sp1702 210 2017-04-16 x

It prints the records of all files that were last updated on April 25, 2017. It must print nothing else.

For example, here is a possible display, which is cooked up because April 25 is a future date.

-r-xr-xr-x 1 cfs264sp170225 cfs264sp1702   40 2017-04-25 abcd

-r--r-xr-x 1 cfs264sp170225 cfs264sp1702   28 2017-04-25 efgh

-rw-r--rw- 1 cfs264sp170225 cfs264sp1702 140 2017-04-25 pqr

The program must work when executed as below.

$ ./p4< name-of-file-that-contains-ls-l-info>

Explanation / Answer

Create a file named p4

add this to file: /bin/sed -n '/2017-04-25/p'

save file

run chmod +x p4

now run command as asked in question.

$ ./p4< name-of-file-that-contains-ls-l-info>

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