Lab1.3-Chapter1
Lab1.3-Chapter1
Exercice 1 :
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.