LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 08-30-2010, 12:10 AM   #1
saurabhmehan
Member
 
Registered: Jul 2010
Posts: 44

Rep: Reputation: 0
Question 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.
 
Old 08-30-2010, 12:15 AM   #2
ghostdog74
Senior Member
 
Registered: Aug 2006
Posts: 2,695
Blog Entries: 5

Rep: Reputation: 241Reputation: 241Reputation: 241
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.
 
Old 08-30-2010, 12:30 AM   #3
saurabhmehan
Member
 
Registered: Jul 2010
Posts: 44

Original Poster
Rep: Reputation: 0
Question 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 View Post
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.
 
  


Reply

Tags
asap


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[bash] Remote file existence check danket Linux - Newbie 5 01-14-2008 04:39 PM
[Question] Check File existence hbinded Programming 3 12-19-2006 05:15 PM
Count occurances of a string in a text file MicahCarrick Linux - Software 1 06-24-2006 04:25 PM
Checking existence on remote server MikeAtVillage Programming 2 04-03-2006 11:16 AM
check for existence of file j-me Linux - Newbie 5 07-29-2003 07:58 AM


All times are GMT -5. The time now is 03:38 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration