Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Can someone please help me write a shell script for this?? Write a shell script file_sizes.sh which prints the names of the files in the

Can someone please help me write a shell script for this??

image text in transcribedimage text in transcribed

image text in transcribed

Write a shell script file_sizes.sh which prints the names of the files in the current directory splitting them into three categories: small if the file contains less than 10 lines medium-sized if the file contains between 10 and 100 lines large if the file contains 100 or more lines . Your script should always print exactly three lines of output. Files should be listed in alphabetic order on each line. Your shell-script should match character-for-character the output shown in the example below. Notice the creation of a separate directory for testing and the use of the script from the last question to produce test files. You could also produce test files manually using an editor. $ mkdir test $ cd test $ ../echon.sh 5 text > a $ ../echon.sh 505 text > bbb $ ../echon.sh 17 text > cc $ ../echon.sh 10 text > d $ ../echon.sh 1000 text > e $ ../echon.sh o text > empty $ ls -1 total 24 -rw-r--r-- 1 andrewt andrewt 25 Mar 24 10:37 a -rw-r--r-- 1 andrewt andrewt 2525 Mar 24 10:37 bbb -rw-r--r-- 1 andrewt andrewt 85 Mar 24 10:37 CC -rw-r--r-- 1 andrewt andrewt 50 Mar 24 10:37 d -rw-r--r-- 1 andrewt andrewt 5000 Mar 24 10:37 e -rw-r--r-- 1 andrewt andrewt Mar 24 10:37 empty $ ../file_sizes.sh Small files: a empty Medium-sized files: cod Large files: bbb e HINT: You can use the command wc to discover how many lines are in a file. You probably want to use a subshell $(), if statements, and the [ (test) command

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

DATABASE Administrator Make A Difference

Authors: Mohciine Elmourabit

1st Edition

B0CGM7XG75, 978-1722657802

More Books

Students also viewed these Databases questions

Question

Assessment of skills and interests.

Answered: 1 week ago

Question

Psychological, financial, and career counseling.

Answered: 1 week ago