![]() |
|
|
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 |
| Print word 1 in line 1 and word 2 in line 2 if it matches a pattern | bangaram | Shell Programming and Scripting | 7 | 08-31-2009 06:58 AM |
| Print line if first Field matches a pattern | Raynon | Shell Programming and Scripting | 2 | 01-08-2009 06:07 AM |
| awk to count pattern matches | npatwardhan | Shell Programming and Scripting | 16 | 12-13-2008 12:20 PM |
| How to get the count only if two column matches? | gobinath | Shell Programming and Scripting | 3 | 05-27-2008 05:01 AM |
| Extract if pattern matches | Raynon | Shell Programming and Scripting | 20 | 10-29-2007 04:44 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Perl line count if it matches a pattern
#!/usr/bin/perl
use Shell; open THEFILE, "C:\galileo_integration.txt" || die "Couldnt open the file!"; @wholeThing = <THEFILE>; close THEFILE; foreach $line (@wholeThing){ if ($line =~ m/\\0$/){ @nextThing = $line; if ($line =~ s/\\0/\\LATEST/g){ @otherThing = $line; @grep_results = qx{cleartool diff -ser @nextThing @otherThing}; print "@grep_results\n"; $inserted = grep( "inserted" | "/^>$/" | "wc-l", @grep_results); print "Number of lines Inserted, $inserted\n"; $deleted = grep( "deleted" | "/^>/" | "wc-l", @grep_results); print "Number of lines Deleted, $deleted\n"; $changed = grep( "changed" | "/^>/" | "wc-l", @grep_results); print "Number of lines Changed, $changed\n"; } } } Output it gives is: Number of lines Inserted, 100 Number of lines Deleted, 100 Number of lines Changed, 100 All gives me the same wordcount, but i want to grep line count based on matching Inserted, Deleted, Changed. Output should be like: Number of lines Inserted, 100 Number of lines Deleted, 50 Number of lines Changed, 220 I donot have any clue to match the patterns and retrieve the line count. Please help me. Thanks!!! |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|