Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Linux Shell Scripting Bootcamp

You're reading from   Linux Shell Scripting Bootcamp The fastest way to learn Linux shell scripting

Arrow left icon
Product type Paperback
Published in Jul 2017
Publisher Packt
ISBN-13 9781787281103
Length 208 pages
Edition 1st Edition
Tools
Arrow right icon
Author (1):
Arrow left icon
James K Lewis James K Lewis
Author Profile Icon James K Lewis
James K Lewis
Arrow right icon
View More author details
Toc

Table of Contents (12) Chapters Close

Preface 1. Getting Started with Shell Scripting 2. Working with Variables FREE CHAPTER 3. Using Loops and the sleep Command 4. Creating and Calling Subroutines 5. Creating Interactive Scripts 6. Automating Tasks with Scripts 7. Working with Files 8. Working with wget and curl 9. Debugging Scripts 10. Scripting Best Practices Index

Comparison operators for strings

The comparison for strings are different than for numbers. Here is a partial list:

Operator

Explanation

=

This stands for equal to

!=

This stands for not equal to

>

This stands for greater than

<

This stands for less than

Now let's take a look at Script 3:

Chapter 2 - Script 3

  1  #!/bin/sh
  2  #
  3  # 6/13/2017
  4  #
  5  echo "script3"
  6  
  7  # String variables
  8  str1="Kirk"
  9  str2="Kirk"
 10  str3="Spock"
 11  str3="Dr. McCoy"
 12  str4="Engineer Scott"
 13  str5="A"
 14  str6="B"
 15  
 16  echo str1=$str1 str2=$str2 str3=$str3 str4=$str4
 17  
 18  if [ "$str1" = "$str2" ] ; then
 19   echo str1 equals str2
 20  else
 21   echo str1 does not equal str2
 22  fi
 23  
 24  if [ "$str1" != "$str2" ] ; then
 25   echo str1 does not equal str2
 26  else
 27   echo str1 equals str2
 28  fi
 29  
 30...
You have been reading a chapter from
Linux Shell Scripting Bootcamp
Published in: Jul 2017
Publisher: Packt
ISBN-13: 9781787281103
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image