Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Mail Systems
Eclipse Documentation

How To Guides
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Problem Solutions
Privacy Policy




The sed FAQ
Prev Home Next

6.5. 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, use awk or perl if you need to:

  • count fields or words on a line. (awk)
  • count lines in a block or objects in a file.
  • check lengths of strings or do math operations.
  • handle very long lines or need very large buffers. (or gsed)
  • handle binary data (control characters). (perl: binmode)
  • loop through an array or list.
  • test for file existence, filesize, or fileage.
  • treat each paragraph as a line. (well, not always)
The sed FAQ
Prev Home Next

   Reprinted courtesy of Eric Pement. Also available at Design by Interspire