0
   

How to traverse through the files and grep string in unix...

 
 
Reply Wed 23 Nov, 2011 04:14 pm
The thing is I want to write a shell script which will traverse through the log files and it will pick perticular string like client names and date and save the result in a file with pipe as a delimiter.

For Example...

If I am having the list of files such as...

/home/ashish/File.ABC_11-23-2011_090137.log
/home/ashish/File.PQR_11-24-2011_090137.log
/home/ashish/File.MNO_11-25-2011_090137.log
/home/ashish/File.XYZ_11-26-2011_090137.log

Then output should be like...

ABC|11-23-2011
PQR|11-24-2011
MNO|11-25-2011
XYZ|11-26-2011

And this output should be saved in a file.
  • Topic Stats
  • Top Replies
  • Link to this Topic
Type: Question • Score: 0 • Views: 1,860 • Replies: 4
No top replies

 
rosborne979
 
  1  
Reply Wed 23 Nov, 2011 04:26 pm
@Ashish Raval,
You need to look up the usage on commands like, cat, grep, sort and cut. Then just pipe everything together in the right order. You might also need the "find" command as well.
Ashish Raval
 
  1  
Reply Thu 24 Nov, 2011 12:28 pm
@rosborne979,
Hi Rosborne,

Actually I am new to shell scripts and having basic knoledge of all the commands you have mentioned.
Further guidance will be appriciated...
rosborne979
 
  1  
Reply Thu 24 Nov, 2011 08:19 pm
@Ashish Raval,
Unfortunately I don't remember the details myself, as it's been about 20 years since I worked on shell scripts.

But I don't think what you want to do is all that difficult. You can actually do it in a command line by using pipes "|" to pass output from one command to the input of another.

Ashish Raval
 
  1  
Reply Fri 25 Nov, 2011 11:41 am
@rosborne979,
Not an issue Rosborne, Thank you so much for replying fast... Smile
0 Replies
 
 

Related Topics

Rest in peace, Dennis Richie! - Discussion by Thomas
unix script - Question by kumarbit70
Unix Groups - Help - Discussion by cjhsa
 
  1. Forums
  2. » How to traverse through the files and grep string in unix...
Copyright © 2024 MadLab, LLC :: Terms of Service :: Privacy Policy :: Page generated in 0.03 seconds on 04/26/2024 at 04:33:19