How to fix sed command on MacOS with error extra characters after \ at the end of c command?

playerone

Following sed command works on Linux and Windows but fails on MacOS/BSD:

sed -i '/"appId"/c\  \"appId":\  \"'${applicationId}'\",' $capacitorConfigJson

I tried to add ' ' -e

sed -i ' ' -e '/"appId"/c\  \"appId":\  \"'${applicationId}'\",' $capacitorConfigJson

and then script fail with error:

sed: 1: "/"appId"/c\  \"appId":\ ...": extra characters after \ at the end of c command

I found similar solutions to add newline after c\ but it doesn't seems to work.

anubhava

Try this on BSD (OSX) sed:

sed -i.bak '/"appId"/c\ 
"appId": "'${applicationId}'",
' "$capacitorConfigJson"

Note that there is a space after c\

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

sed error complaining "extra characters after command"

From Dev

sed extra characters at end of l command

From Dev

BSD sed: extra characters at the end of d command

From Dev

sed on mac: 'extra characters after p command'

From Dev

why "extra characters after command" error shown for the sed command line shown?

From Dev

sed: -e expression #1, char 10: extra characters after command

From Dev

Sed - How do I remove the extra characters that show up after running the command?

From Dev

How to fix 'command a expects \ followed by text' in my sed on MacOS?

From Dev

How can I fix the following sed command?

From Dev

Why does suffixing an ampersand at the end of a GTK command, result in extra output in the next command after close?

From Dev

Why does suffixing an ampersand at the end of a GTK command, result in extra output in the next command after close?

From Dev

How to fix '.' is not an internal or external command error

From Dev

How can I fix sed invalid command code '?

From Dev

How Do I Fix This SED Command to Find & Replace a String

From Java

How to add characters in word and replace it using sed command in linux

From Dev

How can I escape special characters in a sed "sub-command"?

From Dev

Sed command filtering extra text/removing

From Dev

Android:ellipsize end - Extra Characters after Ellipsis

From Dev

How to use ! in the sed command?

From Dev

strings command printing some extra characters

From Dev

How to Continue a Command after Error in Batch Files?

From Dev

How to fix "yo: command not found" after installing Yeoman

From Dev

How to insert lines after second pattern with linux sed command

From Dev

sed command does not work for certain characters in unix

From Dev

What is the purpose of those special characters in the sed command?

From Dev

fedora sed command replace special characters

From Dev

Sed command for deleting an inclusive range of characters

From Dev

sed command to delete a string containing / ,\ characters

From Dev

How do I get the nc command to end after 2 seconds?

Related Related

  1. 1

    sed error complaining "extra characters after command"

  2. 2

    sed extra characters at end of l command

  3. 3

    BSD sed: extra characters at the end of d command

  4. 4

    sed on mac: 'extra characters after p command'

  5. 5

    why "extra characters after command" error shown for the sed command line shown?

  6. 6

    sed: -e expression #1, char 10: extra characters after command

  7. 7

    Sed - How do I remove the extra characters that show up after running the command?

  8. 8

    How to fix 'command a expects \ followed by text' in my sed on MacOS?

  9. 9

    How can I fix the following sed command?

  10. 10

    Why does suffixing an ampersand at the end of a GTK command, result in extra output in the next command after close?

  11. 11

    Why does suffixing an ampersand at the end of a GTK command, result in extra output in the next command after close?

  12. 12

    How to fix '.' is not an internal or external command error

  13. 13

    How can I fix sed invalid command code '?

  14. 14

    How Do I Fix This SED Command to Find & Replace a String

  15. 15

    How to add characters in word and replace it using sed command in linux

  16. 16

    How can I escape special characters in a sed "sub-command"?

  17. 17

    Sed command filtering extra text/removing

  18. 18

    Android:ellipsize end - Extra Characters after Ellipsis

  19. 19

    How to use ! in the sed command?

  20. 20

    strings command printing some extra characters

  21. 21

    How to Continue a Command after Error in Batch Files?

  22. 22

    How to fix "yo: command not found" after installing Yeoman

  23. 23

    How to insert lines after second pattern with linux sed command

  24. 24

    sed command does not work for certain characters in unix

  25. 25

    What is the purpose of those special characters in the sed command?

  26. 26

    fedora sed command replace special characters

  27. 27

    Sed command for deleting an inclusive range of characters

  28. 28

    sed command to delete a string containing / ,\ characters

  29. 29

    How do I get the nc command to end after 2 seconds?

HotTag

Archive