Linux – “-;” at the end of the bash statement What is the meaning?

“-;” at the end of the bash statement What is the meaning?… here is a solution to the problem.

“-;” at the end of the bash statement What is the meaning?

For example

bwa sampe ref.fa r1.sai r2.sai r1.fq r2.fq | samtools view -bSho out.bam -;

“-;” What is the purpose? Characters at the end? What are they doing? Why are they needed?

Solution

Semicolon End command (End Pipe, I believe, is technically the right statement). If you wish, you can add another command after it, such as

bwa sampe ref.fa r1.sai r2.sai r1.fq r2.fq | samtools view -bSho out.bam -; echo Here is another command.

Otherwise, the semicolon is harmless, but may not be necessary.

Regarding the hyphen before the semicolon, for samtools and many other commands, it means using standard input instead of the input file (or, in some cases, standard output instead of the output file). This is typical Linux/Unix usage.

(Thanks to @phatfingers for verifying the use of the samtools command. )

Related Problems and Solutions