0% found this document useful (0 votes)
38 views21 pages

Linux Programming Syllabus

For read programming
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
Download as docx, pdf, or txt
0% found this document useful (0 votes)
38 views21 pages

Linux Programming Syllabus

For read programming
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1/ 21

B. Tech II Year I Semester Dept.

of Computer Science and


Engineering
Code Category Hours / Week Credits Marks
PCC LAB L T P C CIE SEE Tota
l
0 1 2 2 40 60 100

Pre requisites
Basic Computer fundamentals

Course Objectives

1 To gain an understanding of important aspects related to the Linux


Commands.
2 To understand directory commands.
3 To provide a comprehensive introduction to SHELL programming.
4 To understand file handling utilities
5 To develop ability to use system calls.

Course Outcomes

1 Apply the basic commands in Linux Operating System.


2 Create directories and Shell Script programs.
3 Analyze a given problem and apply requisite facets of Shell
programming.
4 Demonstrate UNIX commands for file handling mechanisms.
5 Develop a C Program for UNIX Commands.

Week 1
Practice Vi Commands
Week 2
Open the file created in
session 1 Add some text
Change some
text Delete
some text Save
the Changes

Week 3
a Create mytable (name of the table) using cat command for the following
data. use tab to separate fields.
1425 Ravi 15.65
4320 Ramu 26.27
6830 Sita 36.15
1450 Raju 21.86
b Use the cat command to display the file, mytable.
c Use the vi command to correct any errors in the file, mytable.
Week 4

a Use the sort command to sort the file mytable according to the first field.
Call the sorted file
mytable (same name)
b Print the file mytable
use the cut and pasre
commandto swap
field2 and 3 mytable.
Call it mytable (same
name)
c Print the new file, mytable
d Logout of the system.
Week 5
a Use the appropriate command to determine your login shell
b Use the /etc/passwd file to verify the result of “step a”.
c Use the who command and redirect the result to a file called myfile1.
Use the more command
to see the contents of myfile1.
d Use the date and who commands in sequence (in one line) such that the
output of date will
display on the screen and the output of who will be redirected to a file
called myfile2.
Use the
more command to check the contents of myfile2.
Week 6
a Write a sed command that deletes the first character in each line in a file.
b Write a sed command that deletes the character before the last character
in each line in a file.
c Write a sed command that swaps the first and second words in each line in a
file.

Week 7
a Pipe your /etc/passwd file to awk, and print out the home directory of each
user.
b Develop an interactive grep script that asks for a word and a file name and
then tells how many lines contain that word.
Week 8
a)Write a shell script that takes a command –line argument and reports on
whether it is directory, a file, or something else.
b Write a shell script that accepts one or more file name as arguments and
converts all of them ercase, provided they exist in the current directory.
c Write a shell script that determines the period for which a specified user is
working on the
System.
Week 9
a Write a shell script to perform the following string operations:
i To extract a sub-string from a given string.
ii To find the length of a given string.
b Write a shell script that accepts a file name starting and ending line
numbers as arguments and
displays all the lines between the given line numbers.
c Write a shell script that deletes all lines containing a specified word in one
or more files supplied as arguments to it.
Week 10
a Write a shell script that computes the gross salary of a employee
according to the
following rules:
i If basic salary is < 1500 then HRA =10% of the basic and DA =90% of the
basic.
ii If basic salary is >=1500 then HRA =Rs500 and DA=98% of
the basic The basic salary is entered interactively through the
key board.
b Write a shell script that accepts two integers as its arguments and
compute the value of first number raised to the power of the second number
Week 11
a) Write an interactive file-handling shell program. Let it offer the user the
choice of copying, removing, renaming, or linking files. Once the user has
made a choice, then program ask the user for the necessary information,
such as the file name, new name and so on.
Week 12
a Write shell script that takes a login name as command – line argument
and reports
when that person logs in
b Write a shell script which receives two file names as arguments. It should
check whether the two file contents are same or not. If they are same then
second file should be deleted.
Week 13
a Write a shell script that displays a list of all the files in the current directory
to which the
user has read, write and execute permissions.
b Develop an interactive script that ask for a word and a file name and
c then tells how many times that word occurred in the file.

Week 14
Write a C program that takes one or more file or directory names as command
line input and reports the following information on the file:
i File type
ii Number of links
iii Read, write and execute permissions
iv Time of last access
(Note: Use stat/fstat system calls)
Week 15
Review

Text Books

1 Unix concepts and applications, Fourth Edition, Sumitabha Das, TMH


2 Introduction to UNIX & SHELL programming, M.G. Venkatesh Murthy,
Pearson Education

Write a C program that takes one or more file names as command line arguments and displays
the information of the file if and only if the file is having >= 5 links.

Write a C program that takes one or more file names as command line arguments and displays
the information of the file if and only if the file is having read, write and execute permissions.

echo "Enter a number: "


read number

reverse=0
original=$number

while [ $number -ne 0 ]


do
remainder=$(( $number % 10 ))
reverse=$(( $reverse * 10 + $remainder ))
number=$(( $number / 10 ))
done

if [ $original -eq $reverse ]


then
echo "$original is a palindrome."
else
echo "$original is not a palindrome."
fi
while [ condition ];
do
# statements
# commands
done

a=0
while [ $a -lt 10 ]
do
echo $a
a=`expr $a + 1`
done

for var in 0 1 2 3 4 5 6 7 8 9
do
echo $var
done

case word in

pattern1)
Statement(s) to be executed if pattern1 matches
;;
pattern2)
Statement(s) to be executed if pattern2 matches
;;
pattern3)
Statement(s) to be executed if pattern3 matches
;;
*)
Default condition to be executed
;;
esac

echo "Which color do you like best?"

echo "1 - Blue"


echo "2 - Red"
echo "3 - Yellow"
echo "4 - Green"
echo "5 - Orange"
read color;
case $color in
1) echo "Blue is a primary color.";;
2) echo "Red is a primary color.";;
3) echo "Yellow is a primary color.";;
4) echo "Green is a secondary color.";;
5) echo "Orange is a secondary color.";;
*) echo "This color is not available. Please choose a different one.";;
esac
Design Thinking Lab

You might also like