Hi guys.
I am new to this forum so cheers
I have a question.
I have created a shell script that puts all the output into 1 file.
The out put is like this:
-----IP------
Data
Data
Data
-----IP------
Data
Data
Data
How can i arrange this to be like this:
IP | Data | Data | Data
192.168.1.1 | Data 123 | Data 123 | Data 123
192.168.1.1 | Data 123 | Data 123 | Data 123
My script is really simple:
for server in $(cat server.txt)
do
echo -------$server------- >> output file
ssh root@$server 'asterisk -rx "core show channels" | grep "active";asterisk -rx "sip show channels" | grep "active"' >> output file
done
Thank you friends
You can use printf
and xargs
for server in $(cat server.txt)
do
printf "%s" "$server"
ssh root@"$server" 'asterisk -rx "core show channels" | grep "active";asterisk -rx "sip show channels" | grep "active"' |
xargs printf " | %s"
printf "\n"
done > outputfile
Thank you
It does put it in a sort of table
Here is the new output
IP | 45 | active | channels | 23 | active | calls | 27 | active | SIP | dialogs
So now i will try to figure out how to fix the output to look cleaner
Thanks again
---------- Post updated at 05:34 PM ---------- Previous update was at 03:07 PM ----------
I am trying to fix this to be like this
IP | Channels | Calls |
192.168.1.1 | 5 active channels | 3 active calls |
But i cannot find any where how i implement the column extension or how to sort this out since the current output is
IP | 45 | active | channels | 23 | active | calls | 27 | active | SIP | dialogs
Thanks for the help guys
We have a rough idea how your current output file looks like.
How about a more exact example?