I have this sed working in Linux and have a few AIX servers I need to use it on as well but keep getting this error and I can't find any information on it even though it's specific.

Got the following to work but the complex one I can't figure out.

$RESULTSFILE="RESULTS.txt"
$echo -en "\nLine1 Connection info\n\nLine2\nERROR:\nError message\n\n" > $RESULTSFILE
$result=`sed -n '/^ERROR:/{p}' $RESULTSFILE`
   sed: 0602-404 Function /^ERROR:/{p} cannot be parsed.
$if [ "$result" == "ERROR:" ]; then echo True; else echo False; fi

More complex sed

$RESULTSFILE="RESULTS.txt"
$echo -en "\nLine1\n\nLine2\n\nMore lines\n--------------------------------------------------------------------------------\nInfo I want to get\nare each of these\n\nlines.\n\nDisconnected...\n\n" > $RESULTSFILE
$result=`sed -n '/^---*/,/Disconnected/{/^---*/d;/^Disconnect*/d;p}' $RESULTSFILE`
    sed: 0602-404 Function /^---*/,/Disconnected/{/^---*/d;/^Disconnect*/d;p} cannot be parsed.
link|improve this question

1  
I've figured it out and because I can't answer my own question yet I decided to add the answer here. The print var is different in AIX instead of Linux the correct way would be to do the following. sed -n '/^ERROR:/,$p' $RESULTSFILE – LF4 Sep 30 '11 at 22:13
I copied your answer and put it below so that you can mark it as an answer for future readers. – WesleyDavid Oct 1 '11 at 0:27
feedback

2 Answers

up vote 1 down vote accepted

The print var is different in AIX instead of Linux the correct way would be to do the following. sed -n '/^ERROR:/,$p' $RESULTSFILE

link|improve this answer
feedback

Probably GNU sed is not as restrictive as UNIX sed.

sed -n '/^ERROR:/{p}/' $RESULTSFILE should do it. See the trailing /.

Reference: http://zotline.com/shownote.zot/NoteNum/2856.html

link|improve this answer
I'm trying to do a check and store the results for an if statement in a script. I added that part. I don't want to do a substitution in the file. This: sed -n '/^ERROR:/,$p' $RESULTSFILE gave me the results I wanted but I'm having trouble doing it to a more complex sed. – LF4 Sep 30 '11 at 22:38
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.