![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Rules & FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Problem with regexp for IP-Adress Pattern | desertchannel | Shell Programming and Scripting | 9 | 05-25-2008 11:37 PM |
| How to extract two words at the same time. | Aejaz | UNIX for Advanced & Expert Users | 6 | 04-30-2008 06:09 AM |
| extract words with even numbr of letters | manish205 | Shell Programming and Scripting | 3 | 02-19-2008 03:18 AM |
| Please help! Sed extract a pattern | zhen | Shell Programming and Scripting | 11 | 09-18-2006 09:36 AM |
| getting file words as pattern matching | arunkumar_mca | High Level Programming | 5 | 05-31-2005 12:28 AM |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
Couldn't find much help on the kind of question I've here:
There is this text file with text as: Line one has a bingo Line two does not have a bingo but it has a tango Bingo is on line three Line four has both tango and bingo Now I would want to search for the pattern "bingo" in this file and split the line to extract the words immediately preceding and following - "bingo". Tried with this script using perl.. but my output file shows no result. #! /usr/bin/perl open (INFILE, "text1.txt"); open (OUTFILE,">outtext1.txt"); while (<INFILE>) { if (s/\w*(\w{1})bingo(\w{1})\w*/\1\2/) { print OUTFILE; } } close (INFILE); close (OUTIFLE); WIth this expression, I expect to get atleast the 2nd line to pass and the output file to have a but ['a bingo but']. But I get an empty outfile. Can someone please point out how to accomplish this? Thanks! |
| Forum Sponsor | ||
|
|
| Thread Tools | |
| Display Modes | |
|
|