Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

If you are comparing Awk vs Perl for scripts, I'd prefer Perl (or Python).

This post is about short one-liners for ad hoc use cases. I prefer sed/awk over Perl for such cases. Though, if you already know Perl, you could continue using it instead of having to learn more tools.



Do all systems still come with Perl baked in these days? If so I could see reaching for that over awk/sed. If I have to install a runtime I may as well just reach for Python


What are "all systems"? Most mainstream Debian or Fedora based systems install Perl by default (but not necessarily in specialized settings such as embedded/boot/rescue systems). Alpine linux does not include it in standard images. FreeBSD (and probably Net/OpenBSD) don't install Perl by default. The current macOS still includes it, but Apple has notified that it will be removed at some point. Windows does not include Perl or awk by default.

Sed and Awk are part of POSIX, and maybe more importantly also part of Busybox. They're almost always available when Perl is available, while the reverse is not true.


>> Do all systems still come with Perl baked in these days?

If you use Git for Windows (https://gitforwindows.org/), it includes Perl.


…and gawk :)


Yes. Frequently any tool set that has gawk will also include sed, perl, cut, head, tail, less, vi / vim, etc.

It is nice that Git for Windows includes bash and all these tools.


A bunch of the default git extensions are written with Perl, so you will find some version of it available on most modern Linux systems




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: