String Manipulation:
String manipulation refers to the process of modifying, extracting, or manipulating strings in shell scripts. It allows you to perform various operations on strings, such as concatenation, substitution, trimming, searching, and more. Shell scripting provides several built-in mechanisms for string manipulation:
1. Concatenation:
* Concatenation combines multiple strings into a single string.
* Example:
```
bash`str1="Hello"
str2="World"
result="$str1 $str2"
echo $result`
```
Output: `Hello World`
2. Substring Extraction:
* Substring extraction allows you to extract a portion of a string based on a starting position and length.
* Example:
```
bash`str="Hello World"
substr=${str:6:5}
echo $substr`
```
Output: `World`
3. String Length:
* You can obtain the length of a string us....
Log in to view the answer