Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.
Perl pattern matching
Name: Carlos Picardal Date: May 3, 2004 at 12:43:50 Pacific OS: AIX 5.0 CPU/Ram: ??
Comment:
I have a line of code that partialy works. It does not work the way i want it! I do not want it to pick up any duplicate entries.
Say I have two entries called car and icar, I just want to pick up car.
search pattern:
if (m/Database name.^$pattern/i)
entries:
Database name = car blah blah blah blah blah blah
Database name = icar blah blah blah blah blah blah
since this is the UNIX forum: grep "^patt" file|sort |uniq -u
0
Response Number 2
Name: FishMonger Date: May 3, 2004 at 21:15:52 Pacific
Reply:
if (Database name = $pattern\b/i)
Dlonra, are you infering that Perl is not a part of UNIX? It's been on every UNIX system that I've used.
0
Response Number 3
Name: FishMonger Date: May 3, 2004 at 21:18:17 Pacific
Reply:
Oops, I left out the leading / on the regex.
0
Response Number 4
Name: Dlonra Date: May 4, 2004 at 05:48:05 Pacific
Reply:
Fishmonger,
PERL was not on the pre-1987 UNIX systems I used. Neither was python nor php - C++ was "C with classes" These each have their own forums.
If I was critiquing Dlonra's solution, I would note that he was attempting to sort a file while Kialos!!23 simply wanted to distinguish between similar patterns.
Summary: Do you need to delete the lines that include the patterns or just the lines inbetween? This perl command will do an inline edit of your file and delete the inbetween lines as well as the pattern matc...
Summary: Ken: I'd use a pattern matching language like perl or awk: # use nawk on Solaris nawk ' { /computer/ $3=400 print $0 } ' file Regards, Nails ...
Summary: I'm using grep to search for a string in a text file once i've found a match what i really want to do is substitute the line above the match. How would i go about doing this? I understand how to use ...