To quote "The Awful Truth about sed" section of the Grymoire, "It is not your fault you don't understand sed." I do, however, understand Perl, so that's what I use. E.g.: `echo 'fubar' | perl -lpe 's/fu/foo/'` It might be a few milliseconds slower-- for example, commenting every line of my 352-line .zshrc (via s/^/#/) takes 0.007s total with Perl (so does `s/^/#/ unless /^\s*#/`) and 0.005s with sed. Commenting out e…
however, perl has -i, which not all seds do, so those 0.002 seconds you lost to perl will be more than gained by being able to type
perl -pi -e 's/foo/bar/' somefile
instead of
sed 's/foo/bar/' somefile > somefile.tmp && mv somefile.tmp somefile
To quote "The Awful Truth about sed" section of the Grymoire, "It is not your fault you don't understand sed." I do, however, understand Perl, so that's what I use. E.g.: `echo 'fubar' | perl -lpe 's/fu/foo/'` It might be a few milliseconds slower-- for example, commenting every line of my 352-line .zshrc (via s/^/#/) takes 0.007s total with Perl (so does `s/^/#/ unless /^\s*#/`) and 0.005s with sed. Commenting out e…
however, perl has -i, which not all seds do, so those 0.002 seconds you lost to perl will be more than gained by being able to type perl -pi -e 's/foo/bar/' somefile instead of sed 's/foo/bar/' somefile > somefile.tmp && mv somefile.tmp somefile
however, perl has -i, which not all seds do, so those 0.002 seconds you lost to perl will be more than gained by being able to type perl -pi -e 's/foo/bar/' somefile instead of sed 's/foo/bar/' somefile > somefile.tmp && mv somefile.tmp somefile
To quote "The Awful Truth about sed" section of the Grymoire, "It is not your fault you don't understand sed." I do, however, understand Perl, so that's what I use. E.g.: `echo 'fubar' | perl -lpe 's/fu/foo/'` It might be a few milliseconds slower-- for example, commenting every line of my 352-line .zshrc (via s/^/#/) takes 0.007s total with Perl (so does `s/^/#/ unless /^\s*#/`) and 0.005s with sed. Commenting out e…
however, perl has -i, which not all seds do, so those 0.002 seconds you lost to perl will be more than gained by being able to type perl -pi -e 's/foo/bar/' somefile instead of sed 's/foo/bar/' somefile > somefile.tmp && mv somefile.tmp somefile
The utility 'sponge' is useful for doing this in the general case.
To quote "The Awful Truth about sed" section of the Grymoire, "It is not your fault you don't understand sed." I do, however, understand Perl, so that's what I use. E.g.: `echo 'fubar' | perl -lpe 's/fu/foo/'` It might be a few milliseconds slower-- for example, commenting every line of my 352-line .zshrc (via s/^/#/) takes 0.007s total with Perl (so does `s/^/#/ unless /^\s*#/`) and 0.005s with sed. Commenting out e…
however, perl has -i, which not all seds do, so those 0.002 seconds you lost to perl will be more than gained by being able to type perl -pi -e 's/foo/bar/' somefile instead of sed 's/foo/bar/' somefile > somefile.tmp && mv somefile.tmp somefile
Rather than -i alone, I always use -i.bak (or whatever you prefer instead of '.bak'). That way, you get (1) in-place editing and (2) a backup. The files you work on are backed up to "file.bak", so that if you make some simple regex mistake with huge negative consequences, you have a ready fix. (And if you do things perfectly, it's easy to run "rm *bak" after you confirm that.)
As the author also explains in the introduction, the compilation is based on the earlier compilation by Eric Pement, available as .txt files on his website.
however, perl has -i, which not all seds do, so those 0.002 seconds you lost to perl will be more than gained by being able to type perl -pi -e 's/foo/bar/' somefile instead of sed 's/foo/bar/' somefile > somefile.tmp && mv somefile.tmp somefile
The utility 'sponge' is useful for doing this in the general case.
Part of the 'moreutils' package, for the curious. The description for sponge on the project homepage reads "soak up standard input and write to a file."
To quote "The Awful Truth about sed" section of the Grymoire, "It is not your fault you don't understand sed." I do, however, understand Perl, so that's what I use. E.g.: `echo 'fubar' | perl -lpe 's/fu/foo/'` It might be a few milliseconds slower-- for example, commenting every line of my 352-line .zshrc (via s/^/#/) takes 0.007s total with Perl (so does `s/^/#/ unless /^\s*#/`) and 0.005s with sed. Commenting out e…
Apparently the Debian kernel team agrees. I just noticed this while building a kernel package:
test -n "$k" || perl -pli~ -e 's/\$\{shlibs:Depends\}\,?//g' debian/control