Posted - Mon, Jan 20, 2020 11:13 AM. If you’ve got a string of items in bash which are delimited by a common character (comma, space, tab, etc) you can split that into an array quite easily. Create indexed arrays on the fly 3) Convert and copy/paste back to … There are two primary ways that I typically read files into bash arrays: Method 1: A while loop. My typical pattern is: 1) Copy/paste or upload your Excel data (CSV or TSV) to convert it to JSON. Online tool to convert your CSV or TSV formatted data to JSON. We can combine read with IFS (Internal Field Separator) to … Note: The code uses the first row of your CSV data to determine the keys in the associative array. Now you can access the array to get any word you desire or use the for loop in bash to print all the words one by one as I have done in the above script. There are numerous libraries and code … GitHub Gist: instantly share code, notes, and snippets. Here’s the output of the above script: Ubuntu Linux Mint Debian Arch Fedora Method 2: Split string using tr command in Bash. This article has been viewed 873 times. Simply (re)define the IFS variable to the delimiter character and assign the values to a new variable using the array=($ ) syntax. bash shell variable array. How to convert file of strings separated by a new line to array. Ask Question Asked 1 year, ... How do I achieve this with just bash or shell execution? The way I usually read files into an array is with a while loop because I nearly always need to parse the line(s) before populating the array. This is the bash split string example using tr (translate) command: Filed Under: Scripts Execute the script. ... create array $(