![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | 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 and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| SED Search Pattern and Replace with the Pattern | racbern | Shell Programming and Scripting | 4 | 03-15-2008 05:59 AM |
| Perl onliner to search the last line with an occurence of a pattern | ammu | Shell Programming and Scripting | 4 | 01-31-2008 01:09 AM |
| Perl: Search for string on line then search and replace text | Crypto | Shell Programming and Scripting | 4 | 01-04-2008 10:24 AM |
| Search for a pattern from the result of search | boopathi_d | Shell Programming and Scripting | 3 | 12-05-2007 09:54 AM |
| Search file for pattern and grab some lines before pattern | frustrated1 | Shell Programming and Scripting | 2 | 12-22-2005 03:41 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Hi,
The following is the command I am trying to use: perl -ne 'print if (/mckinskey@futuron.com/ ? ($c=1) : (--$c > 0)) ; print if (/28/Aug/2008:21*/ ? ($d = 1) : (--$d > 0))' request.log* [m78i5@serv125 ~]$ perl -ne 'print if (/mckinskey@futuron.com/ ? ($c=1) : (--$c > 0)) ; print if (/28/Aug/2008:01:35*/ ? ($d = 1) : (--$d > 0))' request.log* Bareword found where operator expected at -e line 1, near "/28/Aug" (Missing operator before Aug?) syntax error at -e line 1, near "/28/Aug" Search pattern not terminated at -e line 1. [m78i5@serv125 ~]$ perl -ne 'print if (/mckinskey@futuron.com/ ? ($c=1) : (--$c > 0)) ; print if (/28/Aug/2008:01*/ ? ($d = 1) : (--$d > 0))' request.log* Bareword found where operator expected at -e line 1, near "/28/Aug" (Missing operator before Aug?) syntax error at -e line 1, near "/28/Aug" Search pattern not terminated at -e line 1. [m78i5@serv125 ~]$ perl -ne 'print if (/mckinskey@futuron.com/ ? ($c=1) : (--$c > 0)) ; print if (/28/Aug/2008:21*/ ? ($d = 1) : (--$d > 0))' request.log* Bareword found where operator expected at -e line 1, near "/28/Aug" (Missing operator before Aug?) syntax error at -e line 1, near "/28/Aug" Search pattern not terminated at -e line 1. Thanks Last edited by openspark; 08-29-2008 at 12:54 PM.. Reason: Had to change a character and add additional information, |
|
||||
|
The / is being treated as the search term delimiter. Put double-quotes around the date string. Also, you don't need the *. In /28/Aug/2008:21* that really means /28/Aug/2008:2 and zero or more ones. Depending on how strict you want the match, you could use this:
print if ( m"/28/Aug/2008:21" ... But I think you have other issues in your command. I find that complex one-liners like this are better done first as a multi-line perl script file. Get it working, then compress it down to one line, then use it with perl -e. |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|