0% found this document useful (0 votes)
5 views5 pages

Jayesh 5 Os

The document contains practical programming exercises for a B.Tech. IT course on operating systems, focusing on string manipulation and pattern printing using shell scripts. It includes scripts to check for palindromes, convert strings to uppercase, find string lengths, and print various patterns. Each program is accompanied by example code and an enrolment number.

Uploaded by

Ashish Patil
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)
5 views5 pages

Jayesh 5 Os

The document contains practical programming exercises for a B.Tech. IT course on operating systems, focusing on string manipulation and pattern printing using shell scripts. It includes scripts to check for palindromes, convert strings to uppercase, find string lengths, and print various patterns. Each program is accompanied by example code and an enrolment number.

Uploaded by

Ashish Patil
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/ 5

Faculty of Engineering & Technology

Subject: operating system


Subject-Code:203105214
B.Tech. IT Year 2nd Semester: 4rd

Practical -5

Program:- Write a script to check string is palindrome or not.

echo "Enter a String:"


read input
reverse=""

len=${#input}
for ((i=$len-1; i>=0; i--))
do
reverse="$reverse${input: $i:1}"
done
if [ $input == $reverse]
then
echo "$input is palindrome"
else
echo "$input is not palindrome"
fi

Output: -

Enrolment No: 2203031087064


Faculty of Engineering & Technology
Subject: operating system
Subject-Code:203105214
B.Tech. IT Year 2nd Semester: 4rd

Program: Write a script to convert a string from lower case to upper case.

echo "Enter a string in lowercase:"


read string

uppercase_string=$(echo "$string" | tr '[:lower:]' '[:upper:]')


echo "Uppercase string: $uppercase_string"

Program: Write a script to find length of a string.

echo "Enter a string:"


read string

length=$(expr length "$string")

echo "Length of string '$string': $length"

Enrolment No: 2203031087064


Faculty of Engineering & Technology
Subject: operating system
Subject-Code:203105214
B.Tech. IT Year 2nd Semester: 4rd

Program: Write a script to print the following pattern.

a. *
**
***

row=3
for((i=1;i<=row;i++))
do
for((j=1;j<=i;j++))
do
echo -ne "*"
done
echo
done

b. * * *
**
*

row=3
for((i=row;i>=1;i--))
do
for((j=1;j<=i;j++))
do
echo -ne "*"
done
echo
done

Enrolment No: 2203031087064


Faculty of Engineering & Technology
Subject: operating system
Subject-Code:203105214
B.Tech. IT Year 2nd Semester: 4rd

c. *
**
***
N=3
i=0
j=0

while [ $i -le `expr $N - 1` ]


do
j=0

while [ $j -le `expr $N - 1` ]


do
if [ `expr $N - 1` -le `expr $i + $j` ]
then
echo -ne "*"
else
echo -ne " "
fi
j=`expr $j + 1`
done
echo
i=`expr $i + 1`
done

Enrolment No: 2203031087064


Faculty of Engineering & Technology
Subject: operating system
Subject-Code:203105214
B.Tech. IT Year 2nd Semester: 4rd

d. A
AB
ABC
ABCD

read -p "Enter rows:" rows


for ((i=1; i<=rows; i++));
do
for ((j=1; j<=i; j++));
do
printf "\x$(printf %x $((64+j)))"
done
echo
done

e. A
BC
DEF
GHIJ

Enrolment No: 2203031087064

You might also like