Sayed, Irfan (Irfan) wrote:
Hi all,
I need to search a file for a specific string thru perl script.
for example i want to put following condition in the script.
--- > first search the string string1
----> and if that string found then search for another string string2
----> if both the string found then print both the string on shell
prompt
Hi Irfan.
I think you want to search a file for all lines that contain both string 1 and
string2, is that right? This does what you want
> perl -n -e "print if /string1/ and /string2/" file
But it may be that string1 and string2 can be on separate lines. Please could
you calrify for us? Thanks,
Rob
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>