|
|
|
|
|
|
| Author |
Message |
Chris F.A. Johnson *nix forums Guru
Joined: 20 Feb 2005
Posts: 2268
|
Posted: Wed Jul 19, 2006 11:50 pm Post subject:
Re: entires each on separate line
|
|
|
On 2006-07-19, kevin_m wrote:
| Quote: | Hi,
I want to save command output in some variable, for example:
a=`who`
when i print this variable, there are all entries displayed on one
line, but I need each entry on a separate line.
How can I do this?
|
Presumably, you are using a command like this:
echo $a
When $a is expanded, each white-space-separated word becomes a
separate argument, and echo prints it arguments separated by a
space.
If you want to preserve the formatting of $a, quote it:
echo "$a"
Better still, use printf:
printf "%s\n" "$a"
--
Chris F.A. Johnson, author <http://cfaj.freeshell.org>
Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
===== My code in this post, if any, assumes the POSIX locale
===== and is released under the GNU General Public Licence |
|
| Back to top |
|
 |
kevin_m *nix forums beginner
Joined: 14 Jul 2006
Posts: 6
|
Posted: Wed Jul 19, 2006 10:54 pm Post subject:
Re: entires each on separate line
|
|
|
kevin_m napísal(a):
| Quote: | Hi,
I want to save command output in some variable, for example:
a=`who`
when i print this variable, there are all entries displayed on one
line, but I need
each entry on a separate line.
How can I do this?
Thanks
|
I forgot mentioned that I use korn shell |
|
| Back to top |
|
 |
kevin_m *nix forums beginner
Joined: 14 Jul 2006
Posts: 6
|
Posted: Wed Jul 19, 2006 10:51 pm Post subject:
entires each on separate line
|
|
|
Hi,
I want to save command output in some variable, for example:
a=`who`
when i print this variable, there are all entries displayed on one
line, but I need
each entry on a separate line.
How can I do this?
Thanks |
|
| Back to top |
|
 |
Google
|
|
| Back to top |
|
 |
|
|
The time now is Thu Dec 04, 2008 3:37 am | All times are GMT
|
|
Electricity Suppliers | Credit Cards | Duwayne Burnside | Xbox Mod Chip | Loans
|
|
Copyright © 2004-2005 DeniX Solutions SRL
|
|
|
|
Other DeniX Solutions sites:
Unix/Linux blog |
electronics forum |
medicine forum |
science forum |
|
|
Privacy Policy
|
Powered by phpBB © 2001, 2005 phpBB Group
|
|