Question

I don't understand Darwin vs. CentOS. This is not the first command that has failed me. The exact command works fine on CentOS but not on Darwin. I read the man page for sed ON MY MBP and in theory, it should work on MBP.

Can someone tell me what the correct syntax for using sed on Darwin is? The exact same command works on a CentOS server. However, all of the files I need to run sed with are stored on my local development laptop which is a MBP. I don't want to copy all my test files to our remote CentOS server, just to run this stupid cmd that should work in the first place.

This is the cmd I'm trying to run on my MBP:

sed -i 's/instance=ge/blah/g' 100usr_defSemaAvail_mult_12hr.jmx

The error on the MBP says this

sed: 1: "100usr_defSemaAvail_ ...": invalid command code u

Thanks in advance for helping this frustrated soul.

Was it helpful?

Solution

In the BSD version of sed used on the Mac, the -i option requires an argument containing the suffix to use for the backup file. If you don't want to create a backup file, you have to provide an empty argument:

sed -i '' 's/instance=ge/blah/g' 100usr_defSemaAvail_mult_12hr.jmx

The command you entered specified s/instance=ge/blah/g as the suffix, and 100usr_defSemaAvail_mult_12hr.jmx as the editing commands.

This is different from GNU sed used on Linux, which expects the suffix to be attached to the -i option (e.g. -i.bak). So -i by itself means no backup file.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top