Q1. Write a shell script which which ask your name, age, department, and course and lastly give the syntax to display all your information. Script:
echo “Enter Name “ read name echo “Enter !ge “ read age echo “Enter "ept “ read dept echo “Enter #ourse “ read course echo “$nformation %ou %ou Entered is “ echo “Name& 'name echo “!ge& 'age echo “"ept& 'dept echo “#ourse& 'course Output:
1
Q(. Write Write a shell script which asks your Enrolment no., name, name of ) su*+ects and marks o*tained. "isplay these fields *y using echo and eual operator. Script: echo Enter Enroll no read enroll echo Enter Name read name echo Enter name of $st su*+ect read su*1 echo Enter -arks *t read msu*1 echo Enter name of $$nd su*+ect read su*( echo Enter -arks *t read msu*( echo Enter name of $$$rd su*+ect read su*) echo Enter -arks *t read msu*) echo $nformation %ou %ou Entered echo Enroll no/ 'enroll echo Name/ 'name echo -arks *tained echo 'su*1/ 'msu*1 echo 'su*(/ 'msu*( echo 'su*)/ 'msu*) Output:
(
)
Q). Write Write a shell script, declare 0 varia*les and assign values to them. "isplay the values in the given order 1,0,(,),2. Script:
echo 3ive varia*les are echo $st read i echo $$nd read ii echo $$$rd read iii echo $4th read iv echo 4th read v echo n echo varia*les in 1,0,(,),2 echo 'i, 'ii, 'iii, 'iv, 'v Output:
2
Q2. Write Write a shell script that creates a file containing the message that this file is created today i.e. on the current date followed are the users of 5nix at this moment and show the list of users. Script:
echo 6this file is created on '7date 869d9m9y6: and followed are the users. . . . '7who:6 ; cat < 2
Output:
0
Q0. Write a shell script that accepts two file names from the command line, copies the first to second file and display the second file. Script:
echo 6Enter the first file 6 read file1me touch file1me echo “Enter the second file & read file(me touch file(me cp file1me file(me cat 'file(me Output:
=
Q=. Write a shell script that accepts two parameters i.e. two files, append file1 to file( and display file(. Script:
echo Enter first file name read file1 echo Enter second file name read file( cat 'file1 cat 'file( echo !ppending fille. . . . cat 'file1 << 'file( cat 'file1 cat 'file(
Output:
>
Q>. Write a shell script that assigns execute permission to a file. Script:
echo !ssgining executa*le permission. . . chmod 8x file1 echo Executa*le permission assigned. Output:
?
Q?. Write a shell script that accepts one file and directory name and move that file to the directory and show recursive listing and long listing. Script:
echo Enter file name to *e moved read file1 echo Enter directory name read dir1 mv 'file1 'dir1 echo file moved. . . Output:
@
Q@. Write a shell script where we create a directory, move to the directory, create a file. Ahow the present path and display the file. Script:
echo 6Bresent Working "irectory $s 6 pwd mkdir d1 cd d1 echo #reating a new file, use #CD8" to escape cat < file1 echo #ontent in file are cat file1 Output:
1F
Q1F. Write a shell script that asks your name and invite you on current date for a party and append this message to a file name party. Script:
echo Enter %our Name read name echo 6 'name is invited on party on 'date 869d9m9y6 6 < party cat party
Output:
11
11. Write a shell script that reads a file name from command line and changes name to
filename.logname and gives the num*er of links and siGe of the file given as the command line argument.. SCRIPT
OUTPUT:
1(
12. Write a shell script which displays the date in desired format i.e. -onday (0 A eptem*er
(FF=. SCRIPT
OUTPUT:
1)
13. Write a shell script *y which you create a *ranch Husr directory till depth of d0 and using
concept of assigning the path to the varia*les do the movements within this directory path and create two files in each directory from d1. SCRIPT
OUTPUT:
12
14. Write a shell script and declare two varia*les ! and I. Cake static value of !/0 and I/).
Berform all operations on it. SCRIPT
OUTPUT:
10
15. Write a shell script which accepts a num*er and checks whether the num*er is an odd or even num*er . SCRIPT
OUTPUT:
1=
16. Write a shell script to give the result of student. Cake marks of the five su*+ects, student SCRIPT
OUTPUT:
1>
17. Write a shell script which checks the age of the student for swimming. Che condition
are as follows J1F not allowed 1F1? +unior pool only <1? swimming is allowed in depth also SCRIPT
OUTPUT:
1?
18. Write a shell script to find out the gross salary of an employee when the given
information is as under a. $f *asic salary is less than Ds.10FFK LD! / 1F9 of *asic "! / @F9 of *asic *. $f *asic is greater than or eual to Ds.10FFK LD! / 0FFK "! / @?9 of *asic SCRIPT
OUTPUT:
19. Write a shell script to enter a year and show a message whether the year is a leap year or not. 1@
SCRIPT
OUTPUT:
20. Write a shell script using concept of position parameters which copies one file and d isplay
destination file and it should also contain an error message if the source file does not exist (F
SCRIPT
OUTPUT:
21. Write a shell script to calculate the gross salary of an employee whose *asic salary is entered
through key*oard. Lis "!/2F9 of *asic and LD!/(F9 of *asic. (1
SCRIPT
OUTPUT
22. Write a shell script where distance *etween two cities is input through the key*oard in km.
#onvert and print this distance in meters, feet, inches a nd cm.
((
SCRIPT
OUTPUT
23. Write a shell script to find area and perimeter of rectangle. SCRIPT ()
OUTPUT
24. Write shell scrip to find area and circumference of the circle (2
SCRIPT
OUTPUT
(0
25. Write a shell script to find sum of digits of a num*er and check whether the num*er is
palindrome or not. SCRIPT
OUTPUT
(=
(=. Bass a filename as command line argument to script which finds (i. Whether file exists or not. (ii. "isplay the message what type of file it is. (iii. (a. $f the file is an ordinary file check its read permission. $f availa*le display the file else display message read permission denied. (b. #heck its write permission and if availa*le append that file *y your name and course, else display error message. (c. #heck execute permission M if availa*le shows the output of that file. (iv. (a. $f its a directory check its read permission, if availa*le list the directory. (b. #heck its write permissionO if availa*le make a su*directory in that directory. #reate two file in that su* directory that you created +ust now. SCRIPT
(>
5CB5C
(>. Write a menu driven program a. Blace the pwd of user. *. ist the directory of user. c. ong listing the directory of the user and at the same time this long listing is to *e stored in a file. (?
d. #reate a file in your directory and copy this file in your directory. e. -ove the specified file to your parent directory. f. Dename the specified file in the current directory. g. -ake a su* directory in the current directory and change its permission *y taking away all the permission of group and others. SCRIPT
5CB5C
(?. Write a -enu driven program a. #heck the contents of KetcKpasswd file. (@
*. ist of users who have currently logged in. c. Bwd d. Exit A#D$BC
5CB5C
(@. Write a shell script where you accept a character and you have to echo message whether the entered character is a small case, capital case or a digit or a special sym*ol. "isplay error message if more than one character is entered. )F
A#D$BC
5CB5C
)F. Write a shell script where you accept a word and echo the message a. Whether the word *egins with vowel, consonant or a digit. *. #heck whether the word *egins with small case vowel or capital case vowel. )1
c. #hecks whether the word ends with a digit. A#D$BC
5CB5C
)1. Write a shell script where you check whether a. Che word *egins with “a& and ends with “t& *. Che word *egins with “s& and ends with “p& c. !ny word with fixed length of 2 characters. )(
d. "isplay the word starting with “G& and ending with “l& A#D$BC
5CB5C
)(.Write a shell script to print if its a. -orning time, print “Pood -orning& *. !fternoon time, print “Pood !fternoon& c. Evening time print “Pood Evening& ))
A#D$BC
5CB5C
)). Write a shell script for printing calendar. !ccepts month, year and n ame as command line argument. A#D$BC )2
5CB5C
)2. Write a shell script to find a total of a. 3irst @ integers *. !ny five num*ers c. "o option 7*. from command line
)0
SCRIPT
5CB5C
)=
)0. Write a shell script that takes a search string and filename from the terminal and display the result. A#D$BC
5CB5C
)>
)=. Write a shell script that takes pattern and filename as command line arguments and displays the results appropriately i.e. pattern foundKpattern not found.
5CB5C
)?
)>. Write a shell script that accepts only three arguments from command line. Che first is the pattern string, the second is the filename in which the pattern is to *e searched and the third is the filename in which result is to *e stored.
5CB5C
)@
)?. Write a shell script that accepts a filename as a command line and finds out if its a regular file or a directory. $f its regular file, then perform various tests to see if its reada*le, writea*le, executa*le etc.
5CB5C
2F
)@. Write a shell script that computes the factorial of a given num*er.
5CB5C
21
2F. Write a shell script that works like a calendar reminding the user of certain things depending on the day of the week.
5CB5C
2(
21. Write a shell script that changes the extension of group files from text to doc
5CB5C
2)
2(. Write a shell script which will redirect the output of the date command without the time into a file.
5CB5C
22
2). Write a shell script to execute endlessly a loop which displays contents of the current directory, disk space status, and sleep for )Fseconds and display the users currently logged in on the screen.
5CB5C
20
22. Write a shell script that receives two filenames as arguments. $t should check whether content of the two file is same or not. $f they are same, second file should *e deleted.
5CB5C
2=
20. $f a num*er is input through key*oard, write shell script to calculate sum of digits.
5CB5C
2>
2=. Write a shell script that performs a count down either from 1F or from the value that is entered *y the user.
5CB5C
2?
2>. Write a shell script that examines each file in the current directory. 3iles whose names end in old are moved to a directory named old files and files whose name ends with .c are moved to directory named cprograms.
5CB5C
2@
2?. Write a shell script which takes a command line argument of kms and *y default converts that num*er into meters. !lso provide options to convert km to dm and km to cm.
5CB5C
0F
2@. Write a shell script for renaming each file in the directory such that it will have the current shell B$" as an extension. Che shell script should ensure that the directories do not get renamed.
5CB5C
01
0F. Write a shell script to print 3i*onacci series.
5CB5C
0(