0% found this document useful (0 votes)
19 views8 pages

Shell introduction

The document provides an overview of string processing in Bash, a shell language used in Linux systems. It covers basic string operations such as creating, displaying, and concatenating strings, as well as checking for string equality using operators. Additionally, it includes examples of syntax for these operations and a script to compare two strings.

Uploaded by

saranyat2701
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views8 pages

Shell introduction

The document provides an overview of string processing in Bash, a shell language used in Linux systems. It covers basic string operations such as creating, displaying, and concatenating strings, as well as checking for string equality using operators. Additionally, it includes examples of syntax for these operations and a script to compare two strings.

Uploaded by

saranyat2701
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 8

Shell

introduction
String processing
 Bash is a shell language used in Linux systems that
allows users to interact with system through
command-line interface.
 Bash offers several string manipulation capabilities
that can help users manipulate and process text
strings
 Like other programming languages, Bash String is
a data type such as as an integer or floating-point
unit. It is used to represent text rather than
numbers. It is a combination of a set of characters
that may also contain numbers.
Basic String Operations
 Bash provides basic operations for manipulating strings.
To create a string variable in Bash, you simply assign a
value to a variable name
 Mystring=“Hello, world!”
 To display contents of string variable, you can use echo
command –
 echo $mystring
 The output will be
 hello,world!
echo ${#mystring}

 To get length of a string, use ${#} syntax −


 echo${#mystring}
 The output will be −
 13
To concatenate two strings

 use ${} syntax −

 string1="Hello,“
 string2=" world!"
 echo ${string1}${string2}
 The output will be −
 Hello,world!
Equal Operator

 An equal operator (=) is used to check whether two strings


are equal.
 Syntax
 Operand1 = Operand2
#!/bin/bash
#Script to check whether two strings are equal.

str1="WelcometoJavatpoint."
str2="javatpoint"

if [ $str1 = $str2 ];
then
echo "Both the strings are equal."
else
echo "Strings are not equal."
fi
 Like wise following operators are used
 Not Equal Operator
 Less than Operator
 Greater than Operator
 To check if the string length is greater than Zero:

You might also like