Shell command behaves differently in Jupyter notebook cell and in terminal window

In a terminal window, I get

echo 'one\ntwo\nthree'
one\ntwo\nthree

and

echo -e 'one\ntwo\nthree'
one
two
three

While in a Jupyter notebook

!echo 'one\ntwo\nthree'

returns

one
two
three

and

!echo -e 'one\ntwo\nthree'

returns

-e one
two
three

How does a Jupyter notebook interact with shell commands? How do magic commands work?

And is there a plan of supporting shell commands natively in a Jupyter notebook, by which I mean that bash kernels could be supported (if that makes sense)?

I use GNU bash, version 5.0.16(1)-release (x86_64-apple-darwin19.3.0) on macOS 10.15.4 (Catalina).

There already is a bash kernel. See an example of its use in the first page listed after launching on MyBinder from here. In other words once it launches, choose ’ Getting Circos Up and Running’ from the top of the list on the index page.

Also have you tried using the cell magic %%bash instead for this case?

1 Like

Oops, hadn’t realised there was a difference between ! and %%bash. That solves my problem, but I am still wondering what the difference is between the two. Any documentation on that?