I need to put the output of the ps -ef command into a string.
echo'n that string must display the output similiar to how we see the output of ps -ef in commandline.
This is the string
message="this is the output of ps command\n\n
`ps -ef`\n\n
Output Complete"
when I echo $message the output should be something like this:
This is not possible. The line breaks and multiple spaces in the "ps" output will be lost.
What do you want to do with $message ? There will no doubt be another way without putting the output from "ps" into an environment variable.
Please also mention what Operating System and version you have and which Shell you are using.
Thanks for checking methyl and anurag...anurag ,that is not what I needed
methyl, $message is fed into a monitor tool so that it can display the content of $message . I'm trying this for both hp-ux 11.11 and sun 5.9 OS, shell is ksh.let me know if there is any other way out.
The use of proper quoting is essential here. Don't forget to put the double quotes exactly where I put them. I've highlighted them in my previous post.
this is the output of ps command
UID PID PPID TTY STIME COMMAND
Anurag 1856 1 con 00:56:57 /usr/bin/bash
Anurag 18088 1856 con 01:20:13 /usr/bin/pdksh
Anurag 13864 18088 con 01:20:13 /usr/bin/ps
Output Complete
This is the output I'm getting.
Make sure you put double quotes around the variable
echo "$message"
Without double qoute, output will be in a single line.