![]() |
|
|
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 |
| awk Shell Script error : "Syntax Error : `Split' unexpected | Herry | UNIX for Dummies Questions & Answers | 2 | 03-17-2008 11:16 AM |
| error during run: St9bad_alloc - Getting this error while using some conversion progr | sathu_pec | Shell Programming and Scripting | 1 | 01-21-2008 02:38 AM |
| I got error like...syntax error on line 1, teletype | koti_rama | UNIX for Advanced & Expert Users | 2 | 07-07-2007 08:35 PM |
| error reading sections error at install | doelman | SUN Solaris | 2 | 02-05-2007 12:21 PM |
| Error: Internal system error: Unable to initialize standard output file | firkus | UNIX for Dummies Questions & Answers | 2 | 10-25-2005 04:23 PM |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
Error when using sed
Hi,
I have a input file with following contents ---------------------------------------------------------Run Number: 1----------------------------------------------------------- test_run -layout test_vaal -i [ /x/TEST/batch/temp/20070528_ip.txt /x/TEST/batch/temp/20070528__op.txt]|Started|05/28/2007 02:19:30|TEST|8651 ---------------------------------------------------------out_file----------------------------------------------------------- item_id|status_desc|description test_run -layout test_vaal -i [ /x/TEST/batch/temp/20070528_ip.txt /x/TEST/batch/temp/20070528__op.txt]|Completed|05/28/2007 02:19:33|TEST|8651 ---------------------------------------------------------Run Number: 2----------------------------------------------------------- test_run -layout test_vaal -i [ /x/TEST/batch/temp/20070528_ip.txt /x/TEST/batch/temp/20070528__op.txt]|Started|05/28/2007 02:27:25|TEST|24745 ---------------------------------------------------------out_file----------------------------------------------------------- item_id|status_desc|description test_run -layout test_vaal -i [ /x/TEST/batch/temp/20070528_ip.txt /x/TEST/batch/temp/20070528__op.txt]|Completed|05/28/2007 02:27:27|TEST|24745 ---------------------------------------------------------Run Number: 3----------------------------------------------------------- test_run -layout test_vaal -i [ /x/TEST/batch/temp/20070528_ip.txt /x/TEST/batch/temp/20070528__op.txt]|Started|05/28/2007 02:56:32|TEST|5560 ---------------------------------------------------------out_file----------------------------------------------------------- item_id|status_desc|description test_run -layout test_vaal -i [ /x/TEST/batch/temp/20070528_ip.txt /x/TEST/batch/temp/20070528__op.txt]|Completed|05/28/2007 02:56:34|TEST|5560 ---------------------------------------------------------Run Number: 4----------------------------------------------------------- test_run -layout test_vaal -i [ /x/TEST/batch/temp/20070528_ip.txt /x/TEST/batch/temp/20070528__op.txt]|Started|05/28/2007 02:57:32|TEST|11961 ---------------------------------------------------------out_file----------------------------------------------------------- item_id|status_desc|description test_run -layout test_vaal -i [ /x/TEST/batch/temp/20070528_ip.txt /x/TEST/batch/temp/20070528__op.txt]|Completed|05/28/2007 02:57:33|TEST|11961 ---------------------------------------------------------Run Number: 5----------------------------------------------------------- test_run -layout test_vaal -i [ /x/TEST/batch/temp/20070528_ip.txt /x/TEST/batch/temp/20070528__op.txt]|Started|05/28/2007 04:17:31|TEST|24685 ---------------------------------------------------------out_file----------------------------------------------------------- item_id|status_desc|description test_run -layout test_vaal -i [ /x/TEST/batch/temp/20070528_ip.txt /x/TEST/batch/temp/20070528__op.txt]|Completed|05/28/2007 04:17:33|TEST|24685 Input to the script will be test_run -layout test_vaal -i [ /x/TEST/batch/temp/20070528_ip.txt /x/TEST/batch/temp/20070528__op.txt] My job is to extract the last occurance of the expression that is from IP_EXPR|Started tp IP_EXPR|Completed I tried with sed but it gives the following error sed: -e expression #1, char 40: extra characters after command Following is my code IP="test_run -layout test_vaal -i [ /x/TEST/batch/temp/20070528_ip.txt /x/TEST/batch/temp/20070528__op.txt]" IP_FILE="test.txt" EXPR=`echo $IP | sed 's/\[//g' | sed 's/\]//g'` echo "EXPR is : ${EXPR}" EXTRACTED=`cat $IP_FILE | sed 's/\[//g' | sed 's/\]//g' |sed 's/ /!/g' | sed -n "/${EXPR}/,/${EXPR}/p" ` echo "EXTRACTED is : ${EXTRACTED}" Can somebody help me out in this Raghu |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|