cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A228162 Number of bangbangs (!!) in shell substitution when starting with : '!!' and : "!!" '!!'.

This page as a plain text file.
%I A228162 #50 Jun 02 2025 08:36:38
%S A228162 1,2,2,3,5,17,161,15681,159591041,16866847940875521,
%T A228162 189345699699803478502456213711361
%N A228162 Number of bangbangs (!!) in shell substitution when starting with : '!!' and : "!!" '!!'.
%C A228162 Executing the following no-op commands in a unix shell (bash, dash or zsh)
%C A228162 : '!!'
%C A228162 : "!!" '!!'
%C A228162 followed by repeated execution of the last command (arrow-up, enter) leads to a series of substitutions due to the !! (bangbang) operator:
%C A228162 : ": '!!'" '!!'
%C A228162 : ": ': ": '!!'" '!!''" '!!'
%C A228162 : ": ': ": '!!'" ': ": ': ": '!!'" '!!''" '!!'''" '!!'
%C A228162 These commands show a very irregular pattern as some of the single-quotes (') and double quotes(") switch their role from string delimiters to string contents and vice versa.
%C A228162 Also, these commands grow very fast. After a few repetitions, they'll quickly fill the RAM as well as the hard disk (because of the command history file).
%C A228162 This sequence describes the number of bangbangs (!!) of each command.
%H A228162 Volker Diels-Grabsch, <a href="/A228162/b228162.txt">Table of n, a(n) for n = 0..14</a>
%H A228162 Shadab Ahmed, <a href="http://shadabahmed.com/blog/2013/08/16/bang-bang">Bang Bang !!</a>
%H A228162 Robin Houston, <a href="http://bosker.wordpress.com/2013/08/16/using-group-theory-to-understand-unix-command-substitution/">The algebra of Unix command substitution</a>
%F A228162 a(0) = 1, a(1) = 2, a(2) = 2, a(3) = 3, a(4) = 5, and for n >= 5, a(n) = 4*p(n) + 2*q(n) + 1 where p(5) = 2, q(5) = 4, and p(n+1) = 3*p(n)^2 + 2*p(n) + p(n)*q(n) and q(n+1) = 2*p(n)^2 + 2*p(n)*q(n) + 2*q(n).
%e A228162 For n = 4 the value a(4) = 5 is the number of bangbangs (!!) in the following command:
%e A228162 : ": ': ": '!!'" ': ": ': ": '!!'" '!!''" '!!'''" '!!'
%o A228162 (Python)
%o A228162 for i, ai in enumerate([1, 2, 2, 3, 5]):
%o A228162     print('%d %d' % (i, ai))
%o A228162 p, q = 2, 4
%o A228162 for i in range(5, 15):
%o A228162     print('%d %d' % (i, 4*p + 2*q + 1))
%o A228162     p, q = 3*p*p + 2*p + p*q, 2*p*p + 2*p*q + 2*q
%K A228162 nonn
%O A228162 0,2
%A A228162 _Volker Diels-Grabsch_, Aug 16 2013