0% found this document useful (0 votes)
4 views

Lab1.3-Chapter1

The document outlines a series of exercises for a Unix shell scripting lab. It includes tasks such as creating scripts to display system information, check voting eligibility, count image files, and process a text file for specific patterns. Each exercise provides specific requirements and expected outputs for the scripts to be written.

Uploaded by

mam838343
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Lab1.3-Chapter1

The document outlines a series of exercises for a Unix shell scripting lab. It includes tasks such as creating scripts to display system information, check voting eligibility, count image files, and process a text file for specific patterns. Each exercise provides specific requirements and expected outputs for the scripts to be written.

Uploaded by

mam838343
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Operating system Administration : Unix

Lab 1.3 –Shell Scripting

Exercice 1 :

Write a script « greetme.sh » that:


o Contains a comment section with your name, the name of this script, and the purpose of this script.
o Displays the date and the time.
o Displays a calendar for this month.
o Displays the name of your machine.
o Displays the name and version of the operating system.
o Displays a list of all files in your current directory.
o Displays the value of the environment variables TERM, PATH and HOME.
o Displays at the end "Goodbye" and the current time

Exercice 2 :
1. The script « canVote.sh » you will write will take a person’s name and age from the command line (as
arguments). Write a « vote » function that takes these two arguments from the user and determines if
the person can vote. The script calls this function.
2. Modify the script so that the user is asked to enter their name and age.
Use the following output as an example, which uses 18 as the voting age.
$ ./canVote.sh
Name : Ali
Age : 21
Hello Ali, you can vote !

Exercice 3 :
1. Create a script « count_Img.sh » pto count the total number of the « .png » files in the directory
/usr/share/pixmaps. Display this number on the screen.
2. The script also counts the number «.jpg » files and displays the result on the screen.
Note : Soft links will not be taken into consideration when counting.

Exercice 4 :
Write a Shell script « adresses.sh » that takes the file « data2.txt » (given in the appendix) as a parameter and
does the following:
Operating system Administration : Unix

Note: The file « data2.txt » is composed of information blocks per person and has the following form:

Date

Affiliation

Name

Phone number

o Display all the lines that contain a phone number with an extension the letter x or X followed by four digits.
o Display all the lines that start with three digits followed by a dash.
o Display all the lines that start with a capital S.
o Saves the list of people with their phone numbers in a new file « pers_num.txt »

Note : Before each display add a line describing the result to be displayed.

You might also like