Unix and Shell Programming - Dec 2013
Computer Science Engg. (Semester 4)
TOTAL MARKS: 100
TOTAL TIME: 3 HOURS (1) Question 1 is compulsory.
(2) Attempt any four from the remaining questions.
(3) Assume data wherever required.
(4) Figures to the right indicate full marks. 1 (a) Describe briefly the major features of the UNIX operating system.(8 marks) 1 (b) Define a file with example, explain the three categories of files supported by UNIX.(6 marks) 1 (c) Briefly describe:
i) System calls
iii) HOME(6 marks) 2 (a) Explain the significance of all the fields of 'ls - l' output. Which of the attributed can be changed only by the super user?(8 marks) 2 (b) With a neat diagram, explain the three modes of vi editor.(6 marks) 2 (c) Assuming that a file's current permission are rw-r-xr--. Specify the chmod expression (using both relative and absolute methods) required to change them to
i) rwx rwx rwx
ii) r_ _ r_ _ _ _ _
iii) _ _ _ r_ _ r_ _(6 marks) 3 (a) Devise wild-card patterns to match file names:
i) Comprising of atlest three characters where the first char is numeric and the last char is not alphabetic.
ii) With three character extension except the one with .log extension.
iii) Containing 2004 as an embedded string except at the beginning or end.(6 marks) 3 (b) Explain the three distinct phases of process creation. How is the shell created?(8 marks) 3 (c) What are environment variables? Briefly describe any five of them.(6 marks) 4 (a) Distinguish between hard link and symbolic links with suitable examples.(8 marks) 4 (b) Describe the sort filter and illustrate its usage with -k, -u, -n, -r and -c options.(6 marks) 4 (c) i) Use find to locate all files named a.out and all C source files in your home directory tree and remove them interactively.
ii) Display only the names of all user who are logged in and also store that result in user.txt
iii) Invoke the vi editor with the last modified file.(6 marks) 5 (a) Explain with suitable examples, the sed filter along with its two forms of addressing. Also describe in brief the substitution feature provided by sed.(8 marks) 5 (b) Describe the grep filter along with any five options.(6 marks) 5 (c) i) Use sed to delete all blanks lines from a file named sample.
ii) Use grep to list only the sub-directories in the current dictionary.
iii) Replace all occurrences of the word "UNIX" with "LINUX" in a file named sample.(6 marks) 6 (a) Define a shell script. What are the two ways of running a shell script? Write a shell script to accept pattern and a file and search for the pattern in the file.(8 marks) 6 (b) Explain the shell's for loop giving the possible sources of the list.(6 marks) 6 (c) Write a menu-driven shell script to perform the following:
i) List of user who are logged in.
ii) List of files in the current directory
iii) List of processes of user
iv) Today's date
v) Quit to UNIX(6 marks) 7 (a) Describe the awk filter with syntax and example. How are awk arrays different from the ones used in most programming language?(8 marks) 7 (b) Explain the looping constructs supported by awk.(6 marks) 7 (c) Briefly describe the built-in-functions supported by awk for arithmetic and string operations.(6 marks) 8 (a) With examples, explain the string handling functions supported by perl.(8 marks) 8 (b) How are split and join used in perl scripts?(6 marks) 8 (c) Write a perl script to determine whether a year is leap year or not.(6 marks)