SlideShare une entreprise Scribd logo
1  sur  8
Program 1

WAP to concatenate the contents of 2 files ?

cat > first
hai this is first file
^d

cat > second
hai this is Second file
^d

program
-------

vi prog1
echo contents of first file
cat first
echo contents of second file
cat second
echo contents of third file
cat first second > third
cat third
esc : x



output
------

sh prog1

Program 2
WAP to Find SUm,AVG,PRODUCT of 4 numbers ?

vi prog2
clear
echo enter A,B,C,D values

read a
read b
read c
read d

sum= `Expr $a + $b + $c + $d`
Avg= `Expr $sum /4`
Product= `Expr $a * $b * $c *d`

echo Sum is $sum
echo Avg is $Avg
echo Product is $ Product

esc:x

output
------

sh prog2

Program 3
WAP to change two values with out using another variable ?

vi prog3
clear
echo enter A,B values

read a
read b

echo actual values are A="$a" and B="$b"

a=`Expr $a + $b`
b=`Expr $a - $b`
c=`Expr $a - $b`

echo swapped values are "A"=$a and "B"=$b

esc:x

output
-----
sh prog3

Program 4
WAP to find largest of 3 numbers

vi prog4
clear
read a
read b
read c
if [$a -gt $b]

then

if [$a -gt $c]
then echo $a is Bigger
else
echo $c is Bigger
fi

else
if [$b -gt $c]
then
echo $b is Bigger
else
echo $c is Bigger
fi

fi

output
------
sh prog4

Program 5
WAp to find the Factorial of a given number

vi prog5
clear
echo enter the number to get Factorial

read n
fact=1
i=$n

while [$n -ge 1]
do
fact =`Expr $fact * $n`
n=`Expr $n-1`
done

echo Factorial of $i is $fact

output
------

sh prog5

Program 6
WAP to find the Sum of INDIVIDUAL digits of given numbers

vi prog6
clear

echo enter any number having atleast 2 digits

read n
i=$n
r=0
sum=0

while test $n -gt 0
do
r=`Expr $n %10`
sum=`Expr $sum + $r`
n=`Expr $n/10`
done
echo sum of individual digits of $i is $sum

output
-------

sh prog6

Program 7
WAP to find the reverse of a given number

vi prog7
clear
echo enter a number

read n
m=$n
x=0

while test $n -gt 0
do
r=`Expr $n %10`
x=`Expr $n *10 + $r`
n=`Expr $n/10`
done

echo reverse of given number is $x

output
------
sh prog7

Program 8
WAP to generate fibnacci series

vi prog8
clear
echo enter any number

read n
fo=0
f1=1

echo $fo
echo $f1
i=3

while test $i le $n
do
f2=`Expr $fo + $f1`
echo $f2
f0=$f1
f1=$f2
i=`Expr $i+1`
done

output
------
sh prog8

Program 9
WAP to check whether a given number is PALLENDROME or NOT

vi prog9
echo enter any number

read n
x=0
m=$n

while test $n -gt 0
do
r=`Expr $n%10`
x=`Expr $x *10 +r`
n=`Expr $n/10`
done

if test $x -eq $n
then
echo given number is PALLENDROME
else
echo given number is NOT a PALLENDROME
fi

output
------
sh prog9

Program 10
Write a menu Driven Prog

vi prog10

clear
echo "1.Contents of a FILE "
echo
echo "2.Present Working Directory"
echo
echo "3.EXIT"
echo
echo "Enter your Choice"
read ch

case $ch in
1)echo enter file name
read filename
cat $filename
;;
2)echo present working directory
pwd
;;
3)echo program EXIT
;;
*)echo Incorrect choice
;;
esac

output
-------
sh prog10

Program 11
WAP to count the no.of UPPER case letters , no.of lowercase letters, no.of digits
and no.of DIGITS and no.of Special characters in a given string

vi prog11
clear
echo enter a string

read s
len=`echo $s |wc-c`
h=`echo $len -1`
echo length is $h

u=0
l=0
d=0
sc=0

while test $n -gt 0
do
a=`echo $s |cat-c $n`
case $a in

[a-z])
l=`Expr $l+1`
;;

[A-Z])
u=`Expr $u+1`
;;

[0-9])
d=`Expr $d+1`
;;

*)
sc=`Expr $sc+1`
;;
esac
n=`Expr $n-1`
done

echo no.of uppercase letters are $u
echo no.of lowercase letters are $l
echo no.of digits are $d
echo no.of special characters are $sc

Contenu connexe

Tendances

เธเธฒเธฃเน€เธ‚ เธขเธ™เธ„เธณเธช _เธ‡เธ„เธงเธšเธ„_เธกเธ‚__เธ™เธž__เธ™เธเธฒเธ™
เธเธฒเธฃเน€เธ‚ เธขเธ™เธ„เธณเธช _เธ‡เธ„เธงเธšเธ„_เธกเธ‚__เธ™เธž__เธ™เธเธฒเธ™เธเธฒเธฃเน€เธ‚ เธขเธ™เธ„เธณเธช _เธ‡เธ„เธงเธšเธ„_เธกเธ‚__เธ™เธž__เธ™เธเธฒเธ™
เธเธฒเธฃเน€เธ‚ เธขเธ™เธ„เธณเธช _เธ‡เธ„เธงเธšเธ„_เธกเธ‚__เธ™เธž__เธ™เธเธฒเธ™Boom Baphomet
 
การเข ยนคำส _งควบค_มข__นพ__นฐาน (1)
การเข ยนคำส _งควบค_มข__นพ__นฐาน (1)การเข ยนคำส _งควบค_มข__นพ__นฐาน (1)
การเข ยนคำส _งควบค_มข__นพ__นฐาน (1)HamHam' Kc
 
C Programming Language Part 7
C Programming Language Part 7C Programming Language Part 7
C Programming Language Part 7Rumman Ansari
 
C++ Programming - 2nd Study
C++ Programming - 2nd StudyC++ Programming - 2nd Study
C++ Programming - 2nd StudyChris Ohk
 
C Programming Language Step by Step Part 2
C Programming Language Step by Step Part 2C Programming Language Step by Step Part 2
C Programming Language Step by Step Part 2Rumman Ansari
 
Let's begin resource monitoring with munin 2011 1209 zem_distribution
Let's begin resource monitoring with munin 2011 1209 zem_distributionLet's begin resource monitoring with munin 2011 1209 zem_distribution
Let's begin resource monitoring with munin 2011 1209 zem_distributionMasahito Zembutsu
 
Intro to c programming
Intro to c programmingIntro to c programming
Intro to c programmingPrabhu Govind
 

Tendances (19)

Pratik Bakane C++
Pratik Bakane C++Pratik Bakane C++
Pratik Bakane C++
 
Ps installedsoftware
Ps installedsoftwarePs installedsoftware
Ps installedsoftware
 
8.1
8.18.1
8.1
 
Factorial
FactorialFactorial
Factorial
 
Phpbase
PhpbasePhpbase
Phpbase
 
เธเธฒเธฃเน€เธ‚ เธขเธ™เธ„เธณเธช _เธ‡เธ„เธงเธšเธ„_เธกเธ‚__เธ™เธž__เธ™เธเธฒเธ™
เธเธฒเธฃเน€เธ‚ เธขเธ™เธ„เธณเธช _เธ‡เธ„เธงเธšเธ„_เธกเธ‚__เธ™เธž__เธ™เธเธฒเธ™เธเธฒเธฃเน€เธ‚ เธขเธ™เธ„เธณเธช _เธ‡เธ„เธงเธšเธ„_เธกเธ‚__เธ™เธž__เธ™เธเธฒเธ™
เธเธฒเธฃเน€เธ‚ เธขเธ™เธ„เธณเธช _เธ‡เธ„เธงเธšเธ„_เธกเธ‚__เธ™เธž__เธ™เธเธฒเธ™
 
การเข ยนคำส _งควบค_มข__นพ__นฐาน (1)
การเข ยนคำส _งควบค_มข__นพ__นฐาน (1)การเข ยนคำส _งควบค_มข__นพ__นฐาน (1)
การเข ยนคำส _งควบค_มข__นพ__นฐาน (1)
 
C Programming Language Part 7
C Programming Language Part 7C Programming Language Part 7
C Programming Language Part 7
 
11 1 포인터
11 1 포인터11 1 포인터
11 1 포인터
 
Final ds record
Final ds recordFinal ds record
Final ds record
 
Fork handout
Fork handoutFork handout
Fork handout
 
C program to implement linked list using array abstract data type
C program to implement linked list using array abstract data typeC program to implement linked list using array abstract data type
C program to implement linked list using array abstract data type
 
C++ Programming - 2nd Study
C++ Programming - 2nd StudyC++ Programming - 2nd Study
C++ Programming - 2nd Study
 
C Programming Language Step by Step Part 2
C Programming Language Step by Step Part 2C Programming Language Step by Step Part 2
C Programming Language Step by Step Part 2
 
Let's begin resource monitoring with munin 2011 1209 zem_distribution
Let's begin resource monitoring with munin 2011 1209 zem_distributionLet's begin resource monitoring with munin 2011 1209 zem_distribution
Let's begin resource monitoring with munin 2011 1209 zem_distribution
 
week-6x
week-6xweek-6x
week-6x
 
To connect two jframe
To connect two jframeTo connect two jframe
To connect two jframe
 
Intro to c programming
Intro to c programmingIntro to c programming
Intro to c programming
 
Hop ngu MIP
Hop ngu MIPHop ngu MIP
Hop ngu MIP
 

En vedette

Shell Scripts
Shell ScriptsShell Scripts
Shell ScriptsDr.Ravi
 
Unix Shell Scripting Tutorial | Unix Shell Scripting Online Training
Unix Shell Scripting Tutorial | Unix Shell Scripting Online TrainingUnix Shell Scripting Tutorial | Unix Shell Scripting Online Training
Unix Shell Scripting Tutorial | Unix Shell Scripting Online TrainingVyshnavi Reddy
 
Unix shell program training
Unix shell program trainingUnix shell program training
Unix shell program trainingAditya Sharat
 
Unix Shell Script
Unix Shell ScriptUnix Shell Script
Unix Shell Scriptstudent
 
M.TECH 1ST SEM COMPUTER SCIENCE AOS LAB PRGMS 2014
M.TECH 1ST SEM COMPUTER SCIENCE AOS LAB PRGMS 2014M.TECH 1ST SEM COMPUTER SCIENCE AOS LAB PRGMS 2014
M.TECH 1ST SEM COMPUTER SCIENCE AOS LAB PRGMS 2014Supriya Radhakrishna
 
M.TECH 1ST SEM COMPUTER SCIENCE ADBMS LAB PROGRAMS
M.TECH 1ST SEM COMPUTER SCIENCE ADBMS LAB PROGRAMSM.TECH 1ST SEM COMPUTER SCIENCE ADBMS LAB PROGRAMS
M.TECH 1ST SEM COMPUTER SCIENCE ADBMS LAB PROGRAMSSupriya Radhakrishna
 

En vedette (10)

Shell Scripts
Shell ScriptsShell Scripts
Shell Scripts
 
Unix1
Unix1Unix1
Unix1
 
Prog i
Prog iProg i
Prog i
 
Chap06
Chap06Chap06
Chap06
 
Unix Shell Scripting Tutorial | Unix Shell Scripting Online Training
Unix Shell Scripting Tutorial | Unix Shell Scripting Online TrainingUnix Shell Scripting Tutorial | Unix Shell Scripting Online Training
Unix Shell Scripting Tutorial | Unix Shell Scripting Online Training
 
Unix shell program training
Unix shell program trainingUnix shell program training
Unix shell program training
 
Unix Shell Script
Unix Shell ScriptUnix Shell Script
Unix Shell Script
 
Adbms lab manual
Adbms lab manualAdbms lab manual
Adbms lab manual
 
M.TECH 1ST SEM COMPUTER SCIENCE AOS LAB PRGMS 2014
M.TECH 1ST SEM COMPUTER SCIENCE AOS LAB PRGMS 2014M.TECH 1ST SEM COMPUTER SCIENCE AOS LAB PRGMS 2014
M.TECH 1ST SEM COMPUTER SCIENCE AOS LAB PRGMS 2014
 
M.TECH 1ST SEM COMPUTER SCIENCE ADBMS LAB PROGRAMS
M.TECH 1ST SEM COMPUTER SCIENCE ADBMS LAB PROGRAMSM.TECH 1ST SEM COMPUTER SCIENCE ADBMS LAB PROGRAMS
M.TECH 1ST SEM COMPUTER SCIENCE ADBMS LAB PROGRAMS
 

Similaire à basic shell_programs

Similaire à basic shell_programs (20)

32 shell-programming
32 shell-programming32 shell-programming
32 shell-programming
 
Richard practica nº2.php
Richard  practica nº2.phpRichard  practica nº2.php
Richard practica nº2.php
 
Richard practica nº2.php
Richard  practica nº2.phpRichard  practica nº2.php
Richard practica nº2.php
 
C important questions
C important questionsC important questions
C important questions
 
C code examples
C code examplesC code examples
C code examples
 
Good Evils In Perl (Yapc Asia)
Good Evils In Perl (Yapc Asia)Good Evils In Perl (Yapc Asia)
Good Evils In Perl (Yapc Asia)
 
Ruby: OOP, metaprogramming, blocks, iterators, mix-ins, duck typing. Code style
Ruby: OOP, metaprogramming, blocks, iterators, mix-ins, duck typing. Code styleRuby: OOP, metaprogramming, blocks, iterators, mix-ins, duck typing. Code style
Ruby: OOP, metaprogramming, blocks, iterators, mix-ins, duck typing. Code style
 
Paexec -- distributed tasks over network or cpus
Paexec -- distributed tasks over network or cpusPaexec -- distributed tasks over network or cpus
Paexec -- distributed tasks over network or cpus
 
Unix 5 en
Unix 5 enUnix 5 en
Unix 5 en
 
SL-2.pptx
SL-2.pptxSL-2.pptx
SL-2.pptx
 
Data Types Master
Data Types MasterData Types Master
Data Types Master
 
The $path to knowledge: What little it take to unit-test Perl.
The $path to knowledge: What little it take to unit-test Perl.The $path to knowledge: What little it take to unit-test Perl.
The $path to knowledge: What little it take to unit-test Perl.
 
Introduction to php
Introduction to phpIntroduction to php
Introduction to php
 
What's New in Perl? v5.10 - v5.16
What's New in Perl?  v5.10 - v5.16What's New in Perl?  v5.10 - v5.16
What's New in Perl? v5.10 - v5.16
 
Bag of tricks
Bag of tricksBag of tricks
Bag of tricks
 
Simple Photo Processing and Web Display with Perl
Simple Photo Processing and Web Display with PerlSimple Photo Processing and Web Display with Perl
Simple Photo Processing and Web Display with Perl
 
Linux Lab Manual.doc
Linux Lab Manual.docLinux Lab Manual.doc
Linux Lab Manual.doc
 
Web Technology_10.ppt
Web Technology_10.pptWeb Technology_10.ppt
Web Technology_10.ppt
 
C programs
C programsC programs
C programs
 
program in c
program in cprogram in c
program in c
 

Dernier

Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsMebane Rash
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfSherif Taha
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...pradhanghanshyam7136
 
Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxDyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxcallscotland1987
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptxMaritesTamaniVerdade
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.pptRamjanShidvankar
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSCeline George
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - Englishneillewis46
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibitjbellavia9
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structuredhanjurrannsibayan2
 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Association for Project Management
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin ClassesCeline George
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.christianmathematics
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxJisc
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxRamakrishna Reddy Bijjam
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...Nguyen Thanh Tu Collection
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17Celine George
 
Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdfVishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdfssuserdda66b
 

Dernier (20)

Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
 
Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxDyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptx
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
Spatium Project Simulation student brief
Spatium Project Simulation student briefSpatium Project Simulation student brief
Spatium Project Simulation student brief
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structure
 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdfVishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdf
 

basic shell_programs

  • 1. Program 1 WAP to concatenate the contents of 2 files ? cat > first hai this is first file ^d cat > second hai this is Second file ^d program ------- vi prog1 echo contents of first file cat first echo contents of second file cat second echo contents of third file cat first second > third cat third esc : x output ------ sh prog1 Program 2 WAP to Find SUm,AVG,PRODUCT of 4 numbers ? vi prog2 clear echo enter A,B,C,D values read a read b read c read d sum= `Expr $a + $b + $c + $d` Avg= `Expr $sum /4`
  • 2. Product= `Expr $a * $b * $c *d` echo Sum is $sum echo Avg is $Avg echo Product is $ Product esc:x output ------ sh prog2 Program 3 WAP to change two values with out using another variable ? vi prog3 clear echo enter A,B values read a read b echo actual values are A="$a" and B="$b" a=`Expr $a + $b` b=`Expr $a - $b` c=`Expr $a - $b` echo swapped values are "A"=$a and "B"=$b esc:x output ----- sh prog3 Program 4 WAP to find largest of 3 numbers vi prog4 clear read a read b read c
  • 3. if [$a -gt $b] then if [$a -gt $c] then echo $a is Bigger else echo $c is Bigger fi else if [$b -gt $c] then echo $b is Bigger else echo $c is Bigger fi fi output ------ sh prog4 Program 5 WAp to find the Factorial of a given number vi prog5 clear echo enter the number to get Factorial read n fact=1 i=$n while [$n -ge 1] do fact =`Expr $fact * $n` n=`Expr $n-1` done echo Factorial of $i is $fact output
  • 4. ------ sh prog5 Program 6 WAP to find the Sum of INDIVIDUAL digits of given numbers vi prog6 clear echo enter any number having atleast 2 digits read n i=$n r=0 sum=0 while test $n -gt 0 do r=`Expr $n %10` sum=`Expr $sum + $r` n=`Expr $n/10` done echo sum of individual digits of $i is $sum output ------- sh prog6 Program 7 WAP to find the reverse of a given number vi prog7 clear echo enter a number read n m=$n x=0 while test $n -gt 0 do r=`Expr $n %10` x=`Expr $n *10 + $r`
  • 5. n=`Expr $n/10` done echo reverse of given number is $x output ------ sh prog7 Program 8 WAP to generate fibnacci series vi prog8 clear echo enter any number read n fo=0 f1=1 echo $fo echo $f1 i=3 while test $i le $n do f2=`Expr $fo + $f1` echo $f2 f0=$f1 f1=$f2 i=`Expr $i+1` done output ------ sh prog8 Program 9 WAP to check whether a given number is PALLENDROME or NOT vi prog9 echo enter any number read n x=0
  • 6. m=$n while test $n -gt 0 do r=`Expr $n%10` x=`Expr $x *10 +r` n=`Expr $n/10` done if test $x -eq $n then echo given number is PALLENDROME else echo given number is NOT a PALLENDROME fi output ------ sh prog9 Program 10 Write a menu Driven Prog vi prog10 clear echo "1.Contents of a FILE " echo echo "2.Present Working Directory" echo echo "3.EXIT" echo echo "Enter your Choice" read ch case $ch in 1)echo enter file name read filename cat $filename ;; 2)echo present working directory pwd ;; 3)echo program EXIT ;;
  • 7. *)echo Incorrect choice ;; esac output ------- sh prog10 Program 11 WAP to count the no.of UPPER case letters , no.of lowercase letters, no.of digits and no.of DIGITS and no.of Special characters in a given string vi prog11 clear echo enter a string read s len=`echo $s |wc-c` h=`echo $len -1` echo length is $h u=0 l=0 d=0 sc=0 while test $n -gt 0 do a=`echo $s |cat-c $n` case $a in [a-z]) l=`Expr $l+1` ;; [A-Z]) u=`Expr $u+1` ;; [0-9]) d=`Expr $d+1` ;; *) sc=`Expr $sc+1`
  • 8. ;; esac n=`Expr $n-1` done echo no.of uppercase letters are $u echo no.of lowercase letters are $l echo no.of digits are $d echo no.of special characters are $sc