I have a text file in the following format:
cat yourfile.txt
a
b
c
d
e
f
g
I want to convert it to:
a,b,c,d,e,f,g
This is the solution I came up to now:
while read line; do printf "%s%s" $line "," ; done < yourfile.txt
a,b,c,d,e,f,g,
Two issues:
- I am getting an extra comma (,) at the end
- I know I can run this command inside a shell script and exec the shell script from my build.xml. Or there is more elegant solution?