Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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.
share|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. –  Wesley Oct 1 '11 at 0:27

2 Answers 2

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

share|improve this answer

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

share|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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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