remoteserver1
5272 3 service Hit with key
824 4 service Hit with key
641 1000 service Hit with key
264 1000 service Hit with key
91 1000 service Hit with key
76 1 service Hit with key
4 7 service Hit with key
1 1 service Hit with key
I need to output the following format
remoteserver1
5272 3 service Hit with key
824 4 service Hit with key
641 1000 service Hit with key
264 1000 service Hit with key
91 1000 service Hit with key
76 1 service Hit with key
4 7 service Hit with key
1 1 service Hit with key
Hmmm - quoting seems to be a problem - I didn't test the final version when having exchanged my parameters with yours. What is the -C option meant for?
Try
ssh remoteserver1 'hostname 2>&1; awk -F ";" '"'"'{CNT[$4$2 OFS $5]++} END {for (c in CNT) print "", CNT[c], c | "sort -gr"}'"'"' OFS="\t" /var/log/server1.log'
-C Requests compression of all data (including stdin, stdout, stderr, and data for forwarded X11, TCP and UNIX-domain connections). The compression algorithm is the
same used by gzip(1), and the �level� can be controlled by the CompressionLevel option for protocol version 1. Compression is desirable on modem lines and other
slow connections, but will only slow down things on fast networks. The default value can be set on a host-by-host basis in the configuration files; see the
Compression option.
The suggested command is printing tha same output as the per my request without tabing the hostname, any idea buddy?
The tabbing works when I test it. You may want to play around with OFS, and printed (dummy) fields. (I used $4 for my test; change it to $2 for yor case...)
Are you on a slow modem? If not, -C is counterproductive...
I don't understand what you get and what you're after, and where and how they disagree.
My awk proposal prints a <TAB> char in front of every line, and thus has an "empty first column" if the field separator is <TAB>. Your uniq -c approach will print the count as the first field; additional measures have to be taken to prefix a field separator.
Why don't you print the remote server name just outside the ssh line, prefixing it to the entire output?