Created
May 13, 2021 10:04
-
-
Save aahnik/d7d21370e643403c60f9a2cf7d52d905 to your computer and use it in GitHub Desktop.
Convert a bash string to an array of words. Using the IFS (internal field seperator).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export IFS=" " | |
str="hello world what is happening" | |
arr=( $str ) | |
echo first word: ${arr[0]} | |
echo second word: ${arr[1]} | |
echo third word: ${arr[2]} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Output