2

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.
krizzo
  • 387
  • 2
  • 5
  • 16
  • 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 – krizzo 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. – Wesley Oct 01 '11 at 00:27

2 Answers2

1

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

Wesley
  • 32,690
  • 9
  • 82
  • 117
0

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

mailq
  • 17,023
  • 2
  • 37
  • 69
  • 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. – krizzo Sep 30 '11 at 22:38