login
This site is supported by donations to The OEIS Foundation.

 

Logo


Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A228162 Number of bangbangs (!!) in shell substitution when starting with : '!!' and : "!!" '!!' 1
1, 2, 2, 3, 5, 17, 161, 15681, 159591041, 16866847940875521, 189345699699803478502456213711361 (list; graph; refs; listen; history; text; internal format)
OFFSET

0,2

COMMENTS

Executing the following no-op commands in a unix shell (bash, dash or zsh)

: '!!'

: "!!" '!!'

followed by repeated execution of the last command (arrow-up, enter) leads to a series of substitutions due to the !! (bangbang) operator:

: ": '!!'" '!!'

: ": ': ": '!!'" '!!''" '!!'

: ": ': ": '!!'" ': ": ': ": '!!'" '!!''" '!!'''" '!!'

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.

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

This sequence describes the number of bangbangs (!!) of each command.

LINKS

Volker Diels-Grabsch, Table of n, a(n) for n = 0..14

Shadab Ahmed, Bang Bang !!

Robin Houston, The algebra of Unix command substitution

FORMULA

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

EXAMPLE

For n = 4 the value a(4) = 5 is the number of bangbangs (!!) in the following command:

: ": ': ": '!!'" ': ": ': ": '!!'" '!!''" '!!'''" '!!'

PROG

(Python)

for i, ai in enumerate([1, 2, 2, 3, 5]):

....print '%d %d' % (i, ai)

p, q = 2, 4

for i in range(5, 15):

....print '%d %d' % (i, 4*p + 2*q + 1)

....p, q = 3*p*p + 2*p + p*q, 2*p*p + 2*p*q + 2*q

CROSSREFS

Sequence in context: A265789 A055937 A090255 * A080669 A099205 A051005

Adjacent sequences:  A228159 A228160 A228161 * A228163 A228164 A228165

KEYWORD

nonn

AUTHOR

Volker Diels-Grabsch, Aug 16 2013

STATUS

approved

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recent | More pages
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy .

Last modified July 20 14:46 EDT 2017. Contains 289625 sequences.