How to split a string in shell and get first, second and last field

If you are working with bash shell scripts, you might encounter situations where you need to split a string into different fields and extract certain fields from them. Fortunately, most shell scripts come with built-in