simple sed -i problem

$ sed -i 's/testing123/localhost/g' testing123.txt
sed: 1: "testing123.txt": undefined label 'esting123.txt'

The -i switch appears to not work correctly in 10.6.1. From man sed : "If a zero-length extension is given, no backup will be saved". However currently if a zero-length extension is given sed fails. If an extension is given, then sed will work properly:

$ sed -i .backup 's/testing123/localhost/g' testing123.txt
$

uMBP-17 3Ghz, Mac OS X (10.6)

Posted on Sep 10, 2009 10:24 PM

Reply
2 replies

Sep 11, 2009 5:23 AM in response to another_apple_customer

Technically you're not giving a zero-length extension. Whatever comes after the -i is the extension. Sed fails because this interpretation mangles your command. I'm not sure how you would specify a zero-length extension given that something will allows follow the -i. Maybe someone more versed in sed can chime in. I would just make sure there is always an extension.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

simple sed -i problem

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.