Hacker News new | ask | show | jobs
by acqq 4463 days ago
You are right, the shortest awk is one byte. Please post the link all nine variants I wasn't able to Google it.

Still the shortest Perl is 0 bytes when the command line switch is allowed to be -p

Update: That's actually called "the sed mode of Perl." Moreover these two command lines behave similarly:

    perl -pe 's/search/replace/g'
and

    sed 's/search/replace/'
1 comments

SED is shorter (0 byte). SED /is/ a turing complete language [1] so don't try to claim that I'm cheating.

  sed < input > output 
:)

[1] http://robertkotcher.com/sed.html

[update] s/set/sed/

The command line equivalent, with Perl:

    perl -pe '' <input >output
Even java can do that setOut(system.in); (iirc)
> Even java can do that setOut(system.in);

I was referring to an empty SED-program that would then be run via 'sed -f empty-file.sed'. Of course you need >0 bytes to invoke the SED program.