Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Laboratory Organisation - Students can use Linux on their own laptops. - Students must complete their assignments on time and demonstrate their work. - Students

image text in transcribed
image text in transcribed
Laboratory Organisation - Students can use Linux on their own laptops. - Students must complete their assignments on time and demonstrate their work. - Students must submit lab report. Objectives The objectives of the 5 th laboratory session are as follows: 1) Learn how to write shell script programs in the bash shell 2) Learn some bash shell commands 3) Learn how to use heredocs 4) Be able to write shell script programs to solve practical problems Learn shell programming Read/study Chapters 5 of the laboratory manual. Excrcise 1 Using the bash shell commands and utilities, write one line solutions for each of the following problems below and attach the results of these commands. 1) Display the available space in human readable form on the file system for the current directory. (Hint: use the df (see section 3.17.1 of the lab monual on poge 44) and awk's print command (see section 3.28 of the lab manual on page 57 ) 2) Use a Herestring to count the words in the string "And pluck till time and times are done, the silver apples of the moon, the golden apples of the sun". (Hint: see section 5.7.5 of the lab manual, the example on page 103) Exercise 2 Write shell script programs to do the following and attach the results of these programs. 1) Find out how many times the Is command been used in the past 50 history lines and list the result in a file called iscount in your home directory. 2) Find the largest file in your home directory and store that sise in a variable. If the largest file is greater than 1,000,000 bytes in size, then report the flle size to the user. 3) Use a for-loop in a Bash script to iterate through all the files in a directory and count the words in each file that is not itself a directory. (Hint: see section 5.6.4 of the lob manual, the example script on page 911) 4) Write a bash shell script that uses a heredoc to search the following lines of poctry for the word cloths (case insensitive) and print out any lines that contain the search string. Had I the heaver's embroidered cloths, Enwrought with golden and silver light, The blue and the dim and the dark cloths Of night and light and the half-light; I would spread the cloths under your feet. (Hint: see section 5.7.5 of the lab manual, the example script on page 103) 5) Write a script file program, called file_stat, to do the following: - Display the biggest file in your home directory - Display the total number of files in your home directory - Display the number of directory files on your home directory - Display the number of free blocks and the percentage of used space on your home partition. If the number of free blocks is less than 5,000,000 then echo a warning to the terminal, saying "Disk space is running low, n% is used". (Hint: use the df command, see appendix D of the lab manual, the Example problem script on page 308)

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 19th International Conference Dexa 2008 Turin Italy September 2008 Proceedings Lncs 5181

Authors: Sourav S. Bhowmick ,Josef Kung ,Roland Wagner

2008th Edition

3540856536, 978-3540856535

More Books

Students also viewed these Databases questions