0% found this document useful (0 votes)
37 views3 pages

USP LabSetQuestions-Final

The document provides details about the lab assignments for the course "Unix Shell Programming LAB" offered by the Department of Computer Science & Engineering at Siddaganga Institute of Technology. It includes 10 labs divided into 3 parts - Commands, Shell Scripting, and C Programs for Inter-Process Communication. The labs cover basic Unix commands, shell scripting to perform tasks like arithmetic operations and calculating employee salary, and implementing IPC using various techniques like pipes, message queues, shared memory, and semaphores. The final open-ended project involves emulating the 'ls -l' command and demonstrating system calls.

Uploaded by

ashayamal2003
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
37 views3 pages

USP LabSetQuestions-Final

The document provides details about the lab assignments for the course "Unix Shell Programming LAB" offered by the Department of Computer Science & Engineering at Siddaganga Institute of Technology. It includes 10 labs divided into 3 parts - Commands, Shell Scripting, and C Programs for Inter-Process Communication. The labs cover basic Unix commands, shell scripting to perform tasks like arithmetic operations and calculating employee salary, and implementing IPC using various techniques like pipes, message queues, shared memory, and semaphores. The final open-ended project involves emulating the 'ls -l' command and demonstrating system calls.

Uploaded by

ashayamal2003
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Siddaganga Institute of Technology

(An autonomous institution affiliated to VTU, Belagavi, Approved by AICTE, New Delhi,
Accredited by NAAC with 'A' grade & ISO 9001:2015 Certified)
Department of Computer Science & Engineering
(Program Accredited by NBA)

Ability Enhancement Course – Unix Shell Programming LAB


LAB SET QUESTIONS
PART A : COMMANDS

Lab 1:

1. How do you achieve the following using basic unix commands and vi editor:
i) create a file, identify its attributes vi filename,ls -l
ii) edit the file contents using vi editor: insert-lines, words, copy-lines,
words, delete-lines words, cut-lines words, append, search, navigating
across the file chmod 777 filename
iii) change the permissions of the files – both octal and symbolic notations
iv) create a new user and change the ownership of the file sudo useradd username
chown username filename
v) record your login session script
vi) change any 3 terminal characteristics stty -a $stty eof ^k
vii) create a directory structure, remove the current working directory and
navigate across the file system – absolute and relative paths
viii) create hard link and symbolic link for a file and identify the same in
the file system ln source destination

Lab 2: ln -s source destination

2. Create a database file using space as a delimiter. How do you achieve the following?
i) Display first 6 lines of the file
ii) Display last 6 lines of the file
iii) Display lines from 5 to 8 of the file head -8 database.txt | tail -4
iv) Display specified columns from a file cut -c 6-13,19-24 database.txt
v) Combine two files vertically cat m1.txt m2.txt >merge.txt
vi) Sort the file based on field attributes sort -k2 file.txt
vii) Search a given file find -name database.txt -print
viii) Count the number of characters, words and lines in a file wc database.txt
Lab 3:

3. Given a file
i) Redirect the file contents to both terminal and a new file
ii) Enter a wrong command and redirect the error to a error file
iii) Rectify the command and append the output to the same error file
iv) Execute, cat file1.c nofile , Redirect the output of successful command to a
file and error to error file
v) Given two files, compare them using different filters
vi) Redirect the output of a command to /dev/null . What is your observation?
vii) Search a file based on a criteria
viii) Identify suitable command for input redirection
Lab 4:

4. Create a text file, How do you achieve the following using GREP:
i) Remove the blank lines from the file grep . hello.txt

ii) List the 5 character palindromes grep '\(.\)\(.\).\2\1' hello.txt

iii) Select lines that have exactly 5 characters grep '^.....$' hello.txt
iv) Select the lines with leading or trailing zeros grep -E '*0','0*' hello.txt
v) Number the above lines of text grep -n '^.*$' hello.txt

vi) Select lines that do not start with A to K. grep '^[a-k].*$' hello.txt

vii) List the dates available in mon/dd/yyyy grep -E -o '\b[A-Za-z]{3}/[0-9][0-9]/[0-9]{4}\b' hello.txt


viii) Select lines that contain floating point nos. grep -E '\b[0-9]+\.[0-9]+\b' hello.txt
ix) Select the lines that contain only one hex number grep -E -x '0x[0-9a-fA-F]+' hello.txt
x) Simulate wc -l, cat f1 f2. grep -c '.*' hello.txt
grep -a '.*' hello.txt
Lab 5:

5. Create a text file, how do you achieve the following using sed
i. Replace all Read with Retrieve sed 's/read/retrieve/g' hello.txt
ii. Delete the blank line that follows the line that starts with an alphabet. sed '/^$/d'
hello.txt
iii. Double space the file sed 'G' hello.txt

iv. Extract the first word of each line sed 's/ .*//' hello.txt
v. Extract the year from the date in mm/dd/yyyy format sed -n 's/..\/..\/\(....\)/\1/p' hello.txt
vi. Print the line following a pattern match
vii. Merge the odd numbered line and even numbered line. Eg. Merge 1st and
2nd line, 3rd and 4th line , ………………
viii. Delete any integer in each line. sed 's/[0-9]//g' hello.txt
ix. Insert header info “ Summary sheet” available in the file new.txt
x. Simulate copy, head and tail sed -n 'p' hello.txt>new.txt

sed -e '4q' hello.txt


PART B : SHELL SCRIPTING

Lab 6:

Write shell script to perform


i) integer arithmetic operations
ii) reverse string of the given string
Lab 7:
Write a shell script that computes the gross salary of a employee according to the following
a) if basic salary is <1500 then HRA 10% of the basic and DA =90% of the basic
b) if basic salary is >=1500 then HRA 500 and DA =98% of the basic
The basic salary is entered interactively through the keyboard

Lab 8:
Write a shell script that accepts a list of filename as its arguments counts and reports the
occurrence of each word that is present in the first argument file on other argument files.
Lab 9:
Implement menu driven program to do arithmetic calculator operation by reading inputs from
a function
Lab 10:
Write a shell script to check the permission of a file, print filename along with line numbers
and copy the contents of files to another file.

PART C: C Programs for Inter Process Communication (Open Ended Project )


Implement IPC using
i) unnamed pipes, named pipe(FIFO)
ii) message queue
iii) shared memory
iv) semaphores
v) multi threading
vi) process creation using fork
vii) emulate the Unix ls –l command (concept of internal and external command)
viii) demonstrate system call such as stat

You might also like