Hi all, I don't have much experience with shell scripting and I was wondering if there's a shorter way to write this.
Basically, given a list of strings separated by new lines, I want to prepend each string with a prefix and separate the strings with commas
i.e.
stra
strb
strc
becomes
prefix:stra,prefix:strb,prefix:strc
The command I'm currently using is:
cat input | sed 's/^/'text:'/' | tr '\n' ',' | sed 's/,$//g'
This seems a little wordy though for something this simple. Any ideas?
Thanks!