Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Possible Duplicate:
How to Combine find and grep for a complex search? ( GNU/linux, find, grep )

I have a file containing a text:

PADLST20120907:D:05B:UN:IBTA+TK4 17 JFL01+01'BGM+250+C'RFF+TN:TK4

I want to find this file in Linux, using these two strings: "JFL" and "20120907". As you see above, the file contains both "JFL" and "20120907". What should I write in command line? Stirngs may or may not be in the same line.

I want to see file names with full path in the output. I don't want to see error messages or permission denied warnings. I want to search recursively in the directory I am standing in or I would like to specifiy a path.


share|improve this question

marked as duplicate by RedGrittyBrick, 8088, Nifle, BBlake, LawrenceC Sep 13 '12 at 20:51

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

up vote 3 down vote accepted

A simple bash loop will do what you need:

$ grep -rl JFL . | while read n; do grep -l 20120907 $n; done

If your file names contain spaces, do:

$ grep -rl JFL . | while read n; do grep -l 20120907 "$n"; done

To suppress error messages, redirect standard error :

$ grep -rl JFL . 2>/de/null | while read n; do grep -l 20120907 "$n"; done
share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.