Bash doesn't recognize "\" in Ubuntu 18.02

Hi guys, beginner question here, I’ve been using Q2 on mac but just started setting up a new environment on Ubuntu (qiime2-2019.10 running on Ubuntu 18.02 lts). I have a pretty standardized analyzing procedure so I store my codes in a file and I use them as is or tweak arguments as needed, such as:

qiime feature-classifier classify-sklearn \

–i-classifier v3v4_99_classifier.qza \

–i-reads rep-seqs-dada2-mine1.qza \

–o-classification taxonomy-mine1.qza

Which works perfectly on mac but not on ubuntu, it keeps cutting the codes into lines instead of running as a whole. so If I copy the code above to terminal, it returns “missing parameters” as if I only typed in “qiime feature-classifier classify-sklearn \” without passing any arguments, I tried hand typing the exact code in and it works, typing “enter” after “\” will start a new line awaiting input without running just like it should be, so whats the problem? I thought maybe its a system encoding problem so I typed exactly this into text editor and copy/paste but the problem persists, so seems like the “\” only works if Im typing it in and not copying? it works just fine if I copy/paste codes with “\” and “\n” deleted, keeping the traditional bash format, like this: qiime feature-classifier classify-sklearn --i-classifier v3v4_99_classifier.qza --i-reads rep-seqs-dada2-mine1.qza --o-classification taxonomy-mine1.qza. I looked around and there is literally no info around…probably an issue so basic most people solved themselves lol, but Im really stuck, so any help is appreciated, how can I solve this?

I am not sure why you have problems with copying and pasting the commands (I am using Ubuntu and don’t have this problem), but you can make your life a little bit easier by installing Jupyter lab.
To do it, you can activate Qiime2, then run:
conda install -c conda-forge jupyterlab

after it you can launch it by:
jupyter lab

Now you can run any command like:

!qiime feature-classifier classify-sklearn \
  --i-classifier v3v4_99_classifier.qza \
  --i-reads rep-seqs-dada2-mine1.qza \
  --o-classification taxonomy-mine1.qza

with adding “!” like in the example.
Now you don’t need to store all commands in separate file since everything will be in the .ipynb file


Wow great tip, I always avoided the trouble of trying Jupyter series for some lazy reasons but looking at your interface it looks much easier than copy/pasting, will try it now, many thanks for responding!

Same with me, until installed it once. Now I am in love with this set (Qiime2+Jupyter). You also can combine Python commands with Qiime2 to avoid repeating your commands by using loops and conditions.


You can also get a bash kernel here. It’s super easy to install via pip and and one of my favorite things if I just want to do vanilla bash in my notebooks.


strange problem, @Marvin_Yeung, especially your description of typing directly into text editor and copying from there.

The \ is telling the shell to ignore the next character, whatever that next character is. My guess is that either:

  1. you have a space after the \ so the line break is not ignored…
  2. whatever text editor you are using is inserting a CRLF line ending or some other invisible character.

in the default jupyter python kernel you can just put %%bash at the top of the cell and then you don’t need the ! at the start of each command (in that cell).

but if your notebook is 100% bash commands then @jwdebelius’s suggestion to install a jupyter bash kernel is best!