Shell Strings
Strings are scalar and there is no limit to the size of a string.
Any characters, symbols, or words can be used to make up your string.
Strings in Linux Shell Scripting
How to define a string?
We use single or double quotations to define a string.
"Double Quotes" - Anything enclose in double quotes removed meaning of that characters (except \ and $).
'Single quotes' - Enclosed in single quotes remains unchanged.
`Back quote` - To execute command
Example:
#!/bin/bash single='Single quoted' double="Double quoted" echo $single echo $double
Save the above example script as quotes.sh
chmod 755 quotes.sh
./quotes.sh
String Formatting
Character Description
-n Do not output the trailing new line.
-e Enable interpretation of the following backslash escaped characters in the strings:
\a alert (bell)
\b backspace
\c suppress trailing new line
\n new line
\r carriage return
\t horizontal tab
\\ backslash
Example:
#!/bin/bash echo -e "Hello \t Welcome to Linux Shell Scripting"
Related posts:
- Shell Scripting Introduction
- Shell Syntax
- Shell - Strings
- Shell - Variables
- Shell - User Intraction
- First Shell Script
- Shell - Arithmetics
- Shell - Case Statement
- Shell - Command Line Arguments
- Shell - For Loop
- Shell - While Loops
- Shell - IF Statements
- Shell - Input Output Redirections
- Shell - Pipes and Filters
- Shell - Process Management
Your IP address1 is: 172.18.0.2
Tutorials
Latest Updates
Follow us
- Tech-Tutorials twitter.com/techcuriosity