sed command not working in mac

后端 未结 3 561
不思量自难忘°
不思量自难忘° 2021-01-13 05:13

Following sed command is not working on my lion mac.

find . -type f -exec sed -i \'s/user_dashboard/user/g\' {} \\;

I am getting this error

相关标签:
3条回答
  • 2021-01-13 05:33

    -i probably has a different meaning (not "in-place") in your version of sed. Try using gsed if available or replacing -i with -e and using a temporary file (and a mv afterwards) to emulate it.

    0 讨论(0)
  • 2021-01-13 05:43

    The OSX version of sed is not the same as those found in most Linux systems.

    It extends the -i option to give you the opportunity save a file with a different extension, but requires input for that extension.

    If you just want to overwrite the file in place, you need to use sed -i "" ...sedCmd.... fileName to rename your file in-place.

    Per @JamesMcMahon 's comment, see here for the full doc for OSX/BSD sed.

    I hope this helps.

    0 讨论(0)
  • 2021-01-13 05:55

    replacing text inside a text file on the fly with sed on mac is possible.

    the command is just a little different.

    with: -i , you specify an extension where sed will save the original file prior to the sed operation.

    run the command as:

    $ sed -i _bakup -E 's/THESTRING/THEGRANDSTRING' /tmp/jestinkt.txt

    0 讨论(0)
提交回复
热议问题