Vous êtes sur la page 1sur 2

Jaypee Institute of Information Technology, Noida

Assignment 4(Week: Sep 8-20, 2014)

Sub Name: Unix Programming Lab


Topic: Shell Scipt

Sub Code: 10B17CI307

Instructions:
1. Late evaluations will be awarded zero marks.
2. Attendance should be 80 %, otherwise you may be debarred from the lab.
3. Absence from Lab Test 2 will lead to F grade.
4. Notes provided are meant only for guidelines. Notes solely will not cover the syllabus. Read
prescribed books.

Question 1. Quiz 1(10 Marks) [scheduled during 15-20th Sep]


-----------------------------------------------------------------------------------------------------------Read *.pdf in Lab4 Folder. Do following questions:
Imp note:
vi test.sh # create shell script
sh test.sh # execute shell script
Question 2.
a. Write Script to see current date, time, username, and current directory
b. Write a shell script for making a small calculator.
c. Write a script that takes filenames as arguments and displays a special listing of showing
their (i) permissions (ii) size (iii) filename (iv) last modification time (v)last access time..
Question 3. Create a directory with your name and create following files inside it
abc.txt
dcb.c
readme
write a shell script for
a) printing names all files which have characters 'b', 'c' or 'd' in their names.
b) display a count of all files whose name was printed above.
c) prefix the current username to name of all the files of part (1)
Question 4. Write a script data1.sh to carry out the following tasks
a) To count the number of characters, words, and lines in the file called data1 and
display the output on the display screen.
b) To count the number of characters, words, and lines in the output of the ls l
command and display the output on the display screen.
c) Same as in part (b), but redirect the output to a file called data1.stats
Question 5. Make a directory named poem and create five files into it as given below
poem1.txt

From fairest creatures we desire increase,


poem 2.txt
When forty winters shall besiege thy brow,
poem 3.txt
Look in thy glass and tell the face thou viewest
poem4.txt
Unthrifty loveliness, why dost thou spend
poem5.txt
Those hours, that with gentle work did frame
Write a script wildcard.sh to list various files you have create above using wildcards
(a) *
(b)??
(c) [ ]
Question 6. Write shell script to convert the uppercase letters to lowercase of a given
file(file name should be taken as command line argument).
Question 7.Execute the following shell script and carry out the operation below on this
script.
$ vi varscript
# hash are used for comments
#
# Script to test simple shell script
#
myname=Vivek # user defined variable see we didnt define by char or
string
myos = LIUXOS
myno=5
echo "My name is $myname" # echo is equivalent to printf
echo "My os is $myos"
echo "My number is myno, can you see this number"

Rewrite the above script for creating a text file and also put your name in that text file.

Vous aimerez peut-être aussi