Lesson learned

Today I was trying to treat an SVN dump file with sed in order to modify a few of the Node-path values. After finding out that GNU sed has no problem with binary files, I went on to formulate the problem … first on the command line:

sed '/^Node-/s/match/replacement/p' inputfile

The intent should be clear: testing my expressions, i.e. for lines that start with “Node-” replace match with replacement and print it out. From that, however, I got my terminal all garbled since it printed some control characters. Only after re-reading the respective part in the “sed & awk” book from O’Reilly I noticed that it should have been:

sed -n '/^Node-/s/match/replacement/p' inputfile

This way only lines that I tell it to print will make it to the terminal and nothing go garbled anymore.

// Oliver

This entry was posted in EN, Linux, Programming and tagged , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.