When should I ignore sed and use Awk or Perl instead?
If you can write the same script in Awk or Perl and do it in less time, then use Perl or Awk. There’s no reason to spend an hour writing and debugging a sed script if you can do it in Perl in 10 minutes (assuming that you know Perl already) and if the processing time or memory use is not a factor. Don’t hunt pheasants with a .22 if you have a shotgun at your side . . . unless you simply enjoy the challenge! Specifically, if you need to: – heavily comment what your scripts do. Use GNU sed, awk, or perl. – do case insensitive searching. Use gsed302, sedmod, awk or perl. – count fields (words) in a line. Use awk. – count lines in a block or objects in a file. Use awk. – check lengths of strings or do math operations. Use awk or perl. – handle very long lines or need very large buffers. Use gsed or perl. – handle binary data (control characters). Use perl (binmode). – loop through an array or list. Use awk or perl. – test for file existence, filesize, or fileage. Use perl or shell. – treat