I have
a='123, abc, def, ghi'
var1=`echo $a | awk -F", " '{print RS $1}'`
echo "something: $var1"
which outputs
something
123
how can I tell awk not to put a newline between fields? I want it to output:
something: 123
I have
a='123, abc, def, ghi'
var1=`echo $a | awk -F", " '{print RS $1}'`
echo "something: $var1"
which outputs
something
123
how can I tell awk not to put a newline between fields? I want it to output:
something: 123
try using the printf() function without the newline char '\n'
but after I echo "something: $var1" I want to put $var1 in a database, and the newline causes errors there, so I need remove the newline first.
Hi,
I think it could be enough deleting 'RS'. Something like this:
var1=`echo $a | awk -F", " '{print $1}'`
Regards,
yes, that worked, thank you