I have following values in a file in separate lines: California New York Washington South Carolina Kansas
What would be unix script to disp
Use this command tr '\n' ',' < input_file
tr '\n' ',' < input_file
For single quotes use sed -e "s/^/'/" input_file | sed -e "s/$/'/" | tr '\n' ','
sed -e "s/^/'/" input_file | sed -e "s/$/'/" | tr '\n' ','
(Not tested for single/double quote escaping issues)
For variable NEW_VAR=$(echo $VAR | sed -e "s/^/'/" | sed -e "s/$/'/" | tr '\n' ',')
NEW_VAR=$(echo $VAR | sed -e "s/^/'/" | sed -e "s/$/'/" | tr '\n' ',')