Page 1 of 1

Is "Quine" possible in bash?

Posted: Mon Jun 03, 2024 9:35 pm
by greengeek

I stumbled across a site that listed "Quines" - programs that self replicate (well, they output a printout or display of their own code and nothing else useful...).
I wondered if anyone has tried this with Bash??

http://www.nyx.net/~gthompso/quine.htm


Re: Is "Quine" possible in bash?

Posted: Mon Jun 03, 2024 9:54 pm
by williwaw

under unix shells there is...

Author: Bruce Ediger (ediger@rtgds1.den.mmc.com)
Note: I hesitate to include this one. Do NOT run it, as it will fill up your HD
with ease.

a='echo a=$c${a}$c > $$;echo b=$c${b}$c >> $$;echo c=$b${c}$b >> $$; echo $a >> $$;
chmod +x $$; ./$$'
b='"'
c="'"
echo a=$c${a}$c > $$;echo b=$c${b}$c >> $$; echo c=$b${c}$b >> $$;echo $a >> $$; chmod
+x $$; ./$$


Re: Is "Quine" possible in bash?

Posted: Tue Jun 04, 2024 8:29 am
by greengeek
williwaw wrote: Mon Jun 03, 2024 9:54 pm

under unix shells there is...

Oh yes. Didnt spot that - thanks. Actually a few .sh and bash examples there.