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. a) It takes the name of a data file via

ID: 3825369 • Letter: W

Question

Write a sed script that works as below. a) It takes the name of a data file via input redirection. The file used for redirection is the output of the command ls -1 | tail -n +2 >lsfile Here is a sample content. -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 cfs264sp 170225 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 cfs264spi 70225 cfs264sp1702 828 2017-04-16 signindata -rw-r--r-- 1 cfs264sp 170225 cfs264sp1702 210 2017-04-16 x b. 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 c. The program must work when executed as below. $ ./p4

Explanation / Answer

/bin/sed -n '/2017-04-25/p'

save this in a file anmed p4

run chmod +x p4

then run the command in the way provided in question.

Explaniation

-n for not printing any verbose info

'/2017-04-25/' is regex for requried date and p is to print matching line.

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