Search notes:

Linux shell: Using grep to find files matching multiple regular expressions on different lines

The following command finds files below the current working directory that have at least one line that matches the regular expression a.*le and a line that matches the regular expression ba.*na.
$ grep -rli 'a.*le' | xargs -d '\n' grep -li 'ba.*na'
The first part recursively finds files with the pattern a.*le. The file names of these files is then piped into xargs to search for ba.*na.
xargs is given the -d option to delimit incoming file nams on the new line rather than spaces because the first part might return directory or file names with spaces.

Index