Strings In Depth16 / 17
Up next

Split on a delimiter

#!/usr/bin/env bash
csv="red,green,blue"
# setting IFS just for this read splits on commas into an array
IFS=',' read -ra parts <<< "$csv"
echo "count=${#parts[@]} second=${parts[1]}"
What you're solving

IFS controls how read splits fields