-->

DEVOPSZONES

  • Recent blogs

    How to Turn separate lines into a comma separated list with quoted entries in Bash script

     I have the following data :

    heatmap
    data
    ggplot2
    html
    tools

    #!/bin/bash
    input=( $(cat ~/root/list.txt) )
    output=( $(
    for i in ${input[@]}
    do
    echo -ne "'$i',"
    done
    ) )
    output=${output:0:-1}
    echo ${output//,/, }


    Output:

    'heatmap', 'data', 'ggplot2', 'html', 'tools'

    No comments