You are on page 1of 8

Linux Program

TYBCA – 06

bhavinmodi04@gmail.com
Linux Program
1. Write a shell that reads Student No, Name, Sub1, Sub 2, Sub3
marks & generate the formatted marksheet.

Vi stud
If[ $# -ne 5 ]
Then
echo “Usage - $0”
echo “Enter Student No, Name, Sub1, Sub2,
Sub3”
exit 1
If
echo “==============”
echo “Student No :$1”
echo “Student Name :$2”
echo “Sub1 :$3”
echo “Sub2 :$4”
echo “Sub3 :$5”
echo “==============”
2. Write a shell script that display the contents of specified directory.

If[ $# -ne 1 ]

Then

echo “Usage - $0”


exit 1

fi

If cat $1

then

echo –e “\n\nFile$1, found & successfully echoced”

fi

Linux Program tbca-06 Page 2


Linux Program
3. Write a shell script that reads two numbers & find out which one is
greater or both are equal.

Vi greater

If[ $# -ne 2 ]

Then

echo “Usage -$0 x y”

echo “Where x & y are two numbers”

exit 1

fi

n1=$1

n2=$2

If[ $n1 –gt $n2 ]

Then

echo “$n1 is Greater”

elif[ $n2 –gt $n1 ]

Then

echo “$n2 is Greater”

elif[ $n1 –eq $n2 ]

Then

echo “Both are equal”

Else

echo “I can’t figure out which number is greater”

Linux Program tbca-06 Page 3


Linux Program
fi

4. Write a shell script that create menu as follow:

 Copy source file to destination.

 Rename the specified file.

 Print the contents of file.

 Change permission of specified file to (read, write) for all


users.

 Display size of specification file in number of character


(byte).

 Exit

Note: Use case & read appropriate value on choice.

#Copy source to destination

Copy()

cp yy.bak

echo “Copy file, press a key…”

read

return

#Return the specified file

Linux Program tbca-06 Page 4


Linux Program
#

Rename()

my chiocemenu

echo “Rename file, press a key…”

read

return

#Exit

Exited()

exit1

echo “Exit file, press a key…”

read

5. Write a shell script that display detail’s of employees who have


specified designation from the input file.

Note: Create input with (Empno, Empname, Designation )detail’s.

#input file

1. Bhavin Manager

Linux Program tbca-06 Page 5


Linux Program
2. Arpan Assistant

3. Vivek Clerk

#pages 5 file

echo “Enter manager or clerk or assistant to the in input file:- ”

read ch

for w in input

do

grep $ch input

if[ $? –eq 0 ]

then

echo “Found is $w”

else

echo “Not found in $w”

fi

done

6. If cost price & selling price of an item is input though the keyword,
write a program to determine weather the seller has made profit or
loss. Also determined how much profit was made or loss.

Vi price

echo “Enter cost price:, press a key…”

read cp

return

Linux Program tbca-06 Page 6


Linux Program
echo “Enter selling price:, press a key…”

read sp

return

n= expr cp – sp

if[ n –it 0 ]

then

echo “Seller has made loss”

else

echo “Seller has made profit”

fi

7. Write menu driven program which has following options:

 Contents of etc/password

 List of users who have logged in

 Present working directory

 Exit

If test $# = 1

Then

Case $1 in

1) cut -d : -f1,5 /etc/paswd

2) who | cut – d “ ” –f1

Linux Program tbca-06 Page 7


Linux Program
3)

4) exit1

*) echo “Warning - $1 invalid value, only 1,2,3,4 are


allowed”

esac

else

echo “Usage -$0”

echo “Where, value is necessary”

fi

Linux Program tbca-06 Page 8

You might also like