I have many files with wrong opened { brackets from end of line and need to replace it to new line by conditon [a-z)] [{]|[a-z)][{]. input example: public class Test {}expected output: public class Test {}What is wrong in my solution?sed -e '/[a-z)] [{]|[a-z)][{]/s/{/N{/g' *.java -r 
How can I replace opened brackets from end of line to new line using sed?
text processing;sed;osx;regular expression
Since you are doing this on a Mac, this sed will do it:sed 's/{$/\'$'\n{/'Example:echo public class Test {} | sed 's/{$/\'$'\n{/'public class Test {}If you want to edit the file in place execute this command:sed -i  's/{$/\'$'\n{/' javaResult:cat java public class Test {}Here is a reference on inserting newlines in sed on Mac.Tested in OS X 10.11.6