![]() |
|
|
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 |
| grep for pattern | aemunathan | Shell Programming and Scripting | 12 | 05-09-2008 03:58 AM |
| How to grep this pattern?? | askumarece | Shell Programming and Scripting | 13 | 02-20-2008 07:03 AM |
| help with grep the pattern | bluemoon1 | Shell Programming and Scripting | 2 | 09-20-2007 12:27 PM |
| grep the pattern followed by newline | lalelle | Shell Programming and Scripting | 2 | 08-21-2007 09:02 PM |
| grep for more than one pattern | frustrated1 | Shell Programming and Scripting | 4 | 12-13-2005 01:49 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread |
Rating:
|
Display Modes |
|
|
|
||||
|
grep and sed to find a pattern and add newline
Hello All,
I have log file the result from a multithreaded process. So when a process finishes it will write to this log file as 123 rows merged. The issue is sometimes the processess finish at the same time or write to the file at the same time as 123 rows merged.145 rows merged. At the end of the script we do a source count from table and target count from log file. As you can see the above line will fail grep as grep will identify the line and move on while awk will take the first parameter as 123 only. I have used the following command to correct this grep -i "^[0-9].* rows merged" ttt | sed 's/merged\./merged\ /g' | grep -i "^[0-9].* rows merged" | sed '/^$/'d | awk '{print $1}' | while read X do echo $X Y=`expr $Y + $X` done echo $Y TCOUNT=${Y} but there was another instance when this script failed because the log file has something like Commit complete.150 rows merged.Commit complete. The above 150 rows that were merged didn't get counted. I would like to find [0-9].* rows merged anywhere on any line and separate this pattern into a new line EG: the above Commit complete.150 rows merged.Commit complete. should become Commit complete. 150 rows merged. Commit complete. Any help will be greatly appreciated. Thanks |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|