Bash

Bash Quotes

Bash Quotes

In this topic, we'll learn to use quotes in Bash Scripts. once we want variables to store more complex values, we'd like to form use of quotes. Quotes are wont to handle texts and filenames with an area character. it's because Bash uses an area to work out separate items.

When we insert our codes between the quotes, we are telling Bash that the thing between the quotes should be counted as one object. 

Read the subsequent tutorial to know the way to use one quote or double quote:

Quote with String

While working with simple texts and strings, there'll be no differences either we use one quote or double quote.

Check out the instance below:

#! /bin/bash 
#Demonstrating the Bash quotes with some simple examples
echo 'Single quoted text'
echo
echo "double quoted text"

Output:
Text, email

Description automatically generated

Quote with Variable:

It should be stated that the shell variable flexible will only work out with double-quotes. If you define any variable in single quotes, then it'll not be considered as a variable. Let's understand this with an example:

#! /bin/bash  
 
# For now we will only use the echo command
o="Bash shell scripts can be very handy if we use it nicely :) "  
echo "$o"

Output:
Graphical user interface, text, application

Description automatically generated

Here is the output for the above code sippet, While declaring the variable keep in that there shouldn’t be any spaces between = and “ , Otherwise the code won’t work and give you error.