Jump to content

Listing string and file name


Recommended Posts

I have a folder with lots of email files, I want to search for a specific string. I use less and I get the strings I wanted but I dunno which file is comming from. How can I manipulate the output so that the filename is display after the string. Something like this.

> less *

[file1]John has something good in the house..

[file8]standing the good work where I should

 

Thanks.

 

 

[moved from Software by spinynorman]

Link to comment
Share on other sites

grep -H good * | less

 

Wow great stuff, thanks man, now I got a new challenge :cheesy:

Imagine that I want to do this but from a higher level of folders. Actually I am triying to do this on the gaim logs. I had the conversation on ICQ son in Gaim I get just the ID number as the folder name which leaves me pretty lost.

 

So I want to do the grepping from a list of folders and I want the path to be displayed instead of just the filename.

 

Example:

> ls
4323422  2343234  23454
3463334  3454345  375444
>> grep -H good * | less .....
[4323422/23-05-2004.log]  the name of the good stuff....
[3454345/02-12-2004.log]  only good man die...

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...