#!/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]}"
IFS controls how read splits fields