Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1.Write a Bash script, count.sh, which builds a table of counters for the commands under /bin in alphabetical order. For example, there are 9 commands

1.Write a Bash script, count.sh, which builds a table of counters for the commands under /bin in alphabetical order. For example, there are 9 commands starting with "a" (a2p addftinfo addr2line apropos ar arch as ash awk) while there are 11 commands starting with "z" (zcat zcmp zdiff zegrep zfgrep zforce zgrep zless zmore znew zsoelim). Exclude commands starting with non-alphabets such as "[." Your script will print

a 9 ... ... ... z 11 

Use loop and array to design and implement this script.

2.Write a Bash script, reverse.sh, which reverses the contents of a directory passed as a parameter. Assuming /my/dir contains "cache cron games lib log run tmp," your program "reverse.sh /my/dir" will return "tmp run log lib games cron cache." Use an array and two functions: main() and reverse(). You will manually manipulate the list as we did today. DO NOT use the built-in command sort -r.

3.Write a Bash script, filter.sh, which prints those files/directories that have the size greater than the average file size of the directory. Suppose for example that the directory /my/dir has five files/directories with size in parentheses " a (100) b (10) c (100) d (100) e (20)", your program "filter.sh /my/dir" will list "a c d" since the size of each of the three files/directories "a c d" is greater than the average file size of 66. Use three functions: main, average, and filter, where main calls average and filter, and average computes the average file size of a directory and filter filters out those that have less than the average.

4.Write a Bash script, insert-sort.sh, which sorts a list of command line parameters in ascending order. For example, your command will look something like: $ insert-sort.sh 7 2 3 9 -1 and type enter. Your program will return: -1 2 3 7 9

Use only basic commands and array. Do not use any built-in commands that sort array.

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 And Expert Systems Applications 24th International Conference Dexa 2013 Prague Czech Republic August 2013 Proceedings Part 1 Lncs 8055

Authors: Hendrik Decker ,Lenka Lhotska ,Sebastian Link ,Josef Basl ,A Min Tjoa

2013 Edition

3642402844, 978-3642402845

More Books

Students also viewed these Databases questions