Eric M. Ribeiro

Environmental data science

Run bash script from Jupyter in three simple steps

During past weeks I've gone deep in automating processes. Bash scripting was the solution to go, but I`m not a frequent Bash user. However, the possibility to write bash code at Jupyter with all the "shift enter" made it a walk in the park.

If you don't know, Jupyter can handle different language kernels beyond Python1. R and Julia are some other possibilities, not forgetting about bash.

First, make sure you have Anaconda. I recommend you the Miniconda distribution. It does not come with nothing pre-installed but the essential. To install the bash kernel on Jupyter, start creating and activating a new conda env:

conda create -n bashkernel python=3.8
conda activate bashkernel

After, install the Bash Kernel:

conda install -c conda-forge bash_kernel

Run the following command to get it done:

python -m bash_kernel.install

If everything gone ok, you will see the Jupyter launcher with your brand new kernel option. final-result

Very simple, huh?

  1. If you're interested in jupyter kernels, what about my last article on conda envs and Jupyter?