Is "Quine" possible in bash?

For discussions about programming, and for programming questions and advice


Moderator: Forum moderators

Post Reply
User avatar
greengeek
Posts: 1384
Joined: Thu Jul 16, 2020 11:06 pm
Has thanked: 535 times
Been thanked: 192 times

Is "Quine" possible in bash?

Post 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

williwaw
Posts: 1951
Joined: Tue Jul 14, 2020 11:24 pm
Has thanked: 172 times
Been thanked: 369 times

Re: Is "Quine" possible in bash?

Post 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 $$; ./$$

User avatar
greengeek
Posts: 1384
Joined: Thu Jul 16, 2020 11:06 pm
Has thanked: 535 times
Been thanked: 192 times

Re: Is "Quine" possible in bash?

Post 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.

Post Reply

Return to “Programming”