hi all,

im creating a script and i want it to do this -

grep -Ril “text-to-find-here” /path-to-search

but instead of “text-to-find-here” i want to put a file in here, in this file is a bunch of filenames, so -

qwerty.txt

asdfg.txt

zxcvb.txt

poiuy.txt

and the list of file names goes on and on…

and where " /path-to-search " is, is where the directory is that holds a bunch of files and in those files there are loads and loads of lines (as in a previous script i did a find files in a directory and got it to ouput it to a file.txt

and if it finds any patterns i want it to ouput it to another file

im struggling on this bit

cheers,

rob

2 Spice ups

think i have found it the -f option

1 Spice up

this is what my script looks like so far, gonna amend -

#!/bin/bash

echo “enter the path what holds all the files for directory listings”
read -e files

echo “enter the file path what strings you want me to search for”
read -e search

echo “enter the path where the results will be made”
read -e results

echo “what do you want the results file to be called”
read file

cd “$files”

grep -rinf “$search” . >> “$results”/“$file”

i have put the -w option in there aswell so its -rwinf

You can also cat all the files and pipe the grep command like

cat f1.txt f2.txt|grep {condition}