#! /bin/bash sep=$'\t' tempval=$'\n' while IFS= read -r line || [ -n "${line}" ]; do IFS="${sep}" line="${line}${tempval}" a=(${line//"${sep}"/"${tempval}${sep}"}) a=("${a[@]%${tempval}}") for ((i=0; i < ${#a[@]}; i++)) { printf '%s"%s"' "$([ "${i}" -gt 0 ] && printf ',')" "${a[i]}" } echo done
a b c a b b c c b b a b c