nigas
July 21, 2011, 12:27pm
1
Hi,
I want to grep a string from the list of files present in a text file.
I want the output to be printed only when the string is present in a file along with the file name..
I tried some thing like
cat files_list | grep "search_string" $_
I know $_ is wrong but i want something equivalent of this..
Regards,
nigas
yazu
July 21, 2011, 12:32pm
2
Try:
cat files_list | xargs grep "search_string"
nigas
July 21, 2011, 1:04pm
3
Hi yazu,
Sorry but it resulted in the following message
grep: can't open <file1>
grep: can't open <file2>
grep: can't open <file3>
.
.
Regards,
nigas
yazu
July 21, 2011, 1:07pm
4
I believe you are in a directory where there are no files with paths from your files_list.
Is this what you want:
egrep 'sed' $(cat File_List_File)
nigas
July 21, 2011, 1:19pm
6
Just to be sure, i deleted all the files but for 3 in the files list
opened the files list and "gf" ed it to open the individual files
executed -> cat files_list | xargs grep "search_term"
note: the path of the files contains env variables and i checked that the variables are set, hence that should not be an issue.
---------- Post updated at 10:49 PM ---------- Previous update was at 10:48 PM ----------
@Shell_life : i tried the syntax as you mentioned but it prints out that its a illegal variable name (which i guess is because of the usage of $)
Try this other option:
egrep 'sed' `cat File_List_File`
yazu
July 21, 2011, 1:37pm
8
This is the issue. Try just "cat files_list" and see output. The variables wouldn't expand.