LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Parse file from remote server to caculate count of string existence in that file (https://www.linuxquestions.org/questions/linux-newbie-8/parse-file-from-remote-server-to-caculate-count-of-string-existence-in-that-file-829234/)

saurabhmehan 08-30-2010 12:10 AM

Parse file from remote server to caculate count of string existence in that file
 
Hi

I need to parse the file of same name which exist on different servers and calculate the count of string existed in both files.

Say a file abc.log exist on 2 servers.
I want to search for string "test" on both files and calculate the total count of search string's existence.

For example if file abc.log on server 1 has string "test" 2 times
and file abc.log on server 2 has string "test" 4 times.

then the output will be
StringName : Count
example
test : 6 times

Note : I have created the password less connectivity using ssh-keygen.

Please help.

Thanks inn advance.

ghostdog74 08-30-2010 12:15 AM

you can get the count like this for a start
Code:

grep -o pattern file|wc -l
I leave it to you to call this command using ssh.

saurabhmehan 08-30-2010 12:30 AM

Parse file from remote server to caculate count of string existence in that file Reply to Thread
 
Hi Ghostdog,
I need to know how i can access this file without copying on my server using ssh , calculate the count and exit.

thats it



Quote:

Originally Posted by ghostdog74 (Post 4081958)
you can get the count like this for a start
Code:

grep -o pattern file|wc -l
I leave it to you to call this command using ssh.



All times are GMT -5. The time now is 02:09 AM.