Linux – How to wrap this output in quotes

bashlinuxshell

I have the following command, which gives me 99% of what I want:

root@CA2UA5232QPZ:/# tail -3 newtag | awk '{print $1}'
v1.0.20170512.1
v1.0.20170712.1
v1.0.20170712.2
root@CA2UA5232QPZ:/#

But I need to tweak it so the output looks like this:

'v1.0.20170512.1'
'v1.0.20170712.1'
'v1.0.20170712.2'

Best Answer

You could pipe your output to sed:

tail -3 newtag| awk '{print $1}'| sed "s/^/'/;s/$/'/"
Related Question