Hi friends,
Recently I was working in Shell script to replace a content of a file. I have used powershell for windows and shell for mac. This is specific to my build server. I was facing one peculiar issue with sed command usage.
Command Used: sed – i ‘s/oldString/newString/g’ filename
Error: sed: 1: invalid command code J on Mac OS
Though i extension is optional in ubuntu, in mac its mandatory to give it. refer the below highlighted screenshot.
To solve this, I just gave a Empty string Extension like sed – i “” ‘s/oldString/newString/g’ filename. Voila it solved the issue.
I found it hard to solve this issue as I didnt get any clear pointers. So I thought of creating the page,so it will be helpful for developers.
As you note, the argument is optional in Linux (gnu kernel) but required on macOS (BSD kernel).
LikeLike