If you search, you'll see a lot of articles with instructions on how to do it.
There are two patterns depending on whether sed is gnu or not.
Either way, it doesn't work
sed --version
gsed (GNUsed) 4.8
So sed seems to be the gnu version, but
find.-type f | xargs sed-i' 's / Before/After/G'
sed:REerror:illlegal byte sequence
find.-type f | xargs sed-i's /before/after/g'
sed:1: "./vars/front.yml"—invalid command code.
It will be
What's wrong with you?
Run Environment
MAC OS
zsh
Install gnused under the binary name gsed and
I named it sed in alias
First of all, isn't the -i option of sed wrong?
find.-type f|xargs sed's/before/after/g'
I don't think there's any problem with
REerror: I suspect that the regular expression (RE=Regular Expression) before or after replacement is incorrect for the illegal byte sequence
.
LANG=C find.-type f | xargs sed-i' 's / Before/After/G'
How about that?sed:REerror:illegal byte sequence
may be due to a character code error.
find.-type f | xargs sed-i's /before/after/g'
sed:1: "./vars/front.yml"—invalid command code.
appears to be requesting SUFFIX for the i option of sed.
In this environment, I was able to replace it without any problems.
find.-type f | xargs sed-i's /before/after/g'
Environment
$cat/etc/os-release
NAME="Ubuntu"
VERSION="20.04.2 LTS (Focal Fossa)"
ID = ubuntu
ID_LIKE=debian
PRETTY_NAME = "Ubuntu 20.04.2 LTS"
VERSION_ID = "20.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=focal
UBUNTU_CODENAME=focal
$ sed -- version
sed (GNUsed) 4.7
Packaged by: Debian
Copyright (C) 2018 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Author Jay Fenlason, Tom Lord, Ken Pizzini,
Paolo Bonzini, Jim Meyering and Assaf Gordon.
GNUsed home page: <https://www.gnu.org/software/sed/>.
General help using GNU software: <https://www.gnu.org/gethelp/>.
E-mail bug reports to :<[email protected]>.
© 2024 OneMinuteCode. All rights reserved.