In bourne shell I have the following:
VALUES=`some command that returns multiple line values`
echo $VALUES
Looks like:
"ONE"
"TWO"
"THREE"
"FOUR"
I would like it to look like:
"ONE" "TWO" "THREE" "FOUR"
Can anyone help?
In bourne shell I have the following:
VALUES=`some command that returns multiple line values`
echo $VALUES
Looks like:
"ONE"
"TWO"
"THREE"
"FOUR"
I would like it to look like:
"ONE" "TWO" "THREE" "FOUR"
Can anyone help?
echo $VALUES | tr '\n' ' '
<<< i.e. tr -d '\n' <<< "a line with line feed \n". the string doesn't escape '\n' in the double quote as I expected, any idea?echo $VALUES | tr -d '\n', the result would be ONETWOTHREEFOURAnother method, if you want to not just print out your code but assign it to a variable, and not have a spurious space at the end:
$ var=$(tail -1 /etc/passwd; tail -1 /etc/passwd)
$ echo "$var"
apache:x:48:48:Apache:/var/www:/sbin/nologin
apache:x:48:48:Apache:/var/www:/sbin/nologin
$ var=$(echo $var)
$ echo "$var"
apache:x:48:48:Apache:/var/www:/sbin/nologin apache:x:48:48:Apache:/var/www:/sbin/nologin