BCA II Semester – Shell Programming Lab Manual & Viva Questions
BCA II Semester – Shell Programming Lab Manual & Viva Questions
Complete Guide for Lab + Viva Preparation
Introduction
Shell Programming is one of the most important subjects in BCA II Semester. It helps students automate tasks, manage files, and perform system-level operations efficiently.
- Complete Lab Manual Programs (Part A & Part B)
- Detailed Viva Questions with Answers
- Important Commands Table
- Simple explanations for exam preparation
What is Shell Programming?
Shell programming is writing commands in a script file that the shell executes. It acts as an interface between the user and operating system.
Key Features:
- Automation of tasks
- File handling
- Process management
- Loops and conditions
Basic Concepts
Shell
Command-line interpreter.
Shebang
#!/bin/bash
Variables
a=10 echo $a
Input/Output
read a echo $a
PART A – Important Programs
1. Swap Two Numbers
read a b
temp=$a
a=$b
b=$temp
echo "$a $b"
2. Even or Odd
read n
if [ $((n%2)) -eq 0 ]
then echo "Even"
else echo "Odd"
fi
3. Largest of Three
read a b c
if [ $a -gt $b -a $a -gt $c ]
then echo $a
elif [ $b -gt $c ]
then echo $b
else echo $c
fi
4. Factorial
read n
fact=1
while [ $n -gt 1 ]
do
fact=$((fact*n))
n=$((n-1))
done
echo $fact
5. Fibonacci
read n a=0 b=1 for ((i=0;i
PART B – Important Programs
1. Search Element
arr=(10 20 30 40)
read key
for i in "${arr[@]}"
do
if [ $i -eq $key ]
then echo "Found"
fi
done
2. Salary Calculation
read basic
hra=$((basic*20/100))
da=$((basic*10/100))
ta=$((basic*5/100))
total=$((basic+hra+da+ta))
echo $total
3. File Operations
mv old new
rm file
cp file1 file2
4. System Info
whoami
date
ps aux
echo $HOME
Important Viva Questions
- What is shell? Interface between user and OS
- Shell script? File of commands
- chmod? Change permissions
- Process? Program in execution
- fork()? Creates new process
- grep? Search command
- awk? Text processing tool
- Pipe (|)? Connect commands
Conclusion
Shell Programming is essential for system-level operations and automation. Practice programs and focus on logic for best results.
Bonus Tip
- Start with definition
- Explain logic
- Give example
Comments
Post a Comment