This recipe is a bit iterative, but it should re-iterate (pardon the pun) to demonstrate that Bash has a fair number of functionalities built-in to manipulate strings or any structured data. There is a basic assumption though and that is based on many OSes using C programs:
- A string is an array of characters
- Characters such as ',' are the same as any other character
- Therefore, we can evaluate or test for the existence of a character to separate fields from lines and even use this to build arrays
Now, reviewing the steps in this recipe:
- After running the script, we have the following output in the console:
$ builtin-str.shfirst character 1first three characters 123third character onwards 4567890asdfghjklforth to sixth ...