Answer 1a: Touch Passbook - TXT Ls Ls - L Ls - L Passbook - TXT Cat Passbook
Answer 1a: Touch Passbook - TXT Ls Ls - L Ls - L Passbook - TXT Cat Passbook
a. Create an empty file. File name should be taken from the user.
c. Search for a particular pattern in the contents of the file. The search keyword must
2. Write a shell script to find whether a number is even or odd using if-else statement
3. Write a shell script to print the square and cubes of the nos from 1 to 10 using while loop
answer 1a
touch passbook.txt
ls
ls -l
ls -l passbook.txt
cat passbook.txt
answer 1b
!/bin/bash
My first script
answer 1c
answer 1e
answer 1f
$ wc state.txt
5 7 63 state.txt
OR
$ wc capital.txt
5 5 45 capital.txt
answer 1g
answer 1h
rm {file-name}
rm [options] {file-name}
unlink {file-name}
rm -f -r {file-name}
answer 2
answer 3
answer 4
# !/bin/bash
echo "enter a number"
read num
fact=1
while [ $num -ge 1 ]
do
fact=`expr $fact\* $num`
num=’expr $num – 1’
done
echo "factorial of $n is $fact"
answer 5
clear
echo -----------------------------------------------------
echo '\tEvaluation of Arithmetic expression'
echo -----------------------------------------------------
echo Enter the a value
read a
echo Enter the b value
read b
echo 1.Addition
echo 2.Subtraction
echo 3.Multiplication
echo 4.Division
echo 5.Modules
echo Enter your choice
read choice
case $choice in
1)echo Addition : $(expr $a + $b);;
2)echo Suubtraction : $(expr $a - $b);;
3)echo Multiplication : $(expr $a \* $b);;
4)echo Division : $(expr $a / $b);;
5)echo Modules : $(expr $a % $b);;
*)echo This is not a choice
esac