Consider the following command:

echo ’.dump’ | sqlite bacula.db > bacula.sq

What is it doing and what does | do?

Maybe someone could point me to a manual about piping, or explain what is going on. Thanks.

  • You might find this description of the shell at a conceptual level to be very helpful; I certainly did.
    – Wildcard
    Mar 15, 2016 at 9:50
  • It doesn't say that because it's not relevant - echo 'ignores' pipe input in the same way that human eyes 'ignore' ultra-violet or infra-red, or the way that a defenceless vegemite sandwich 'ignores' the fact that it is approaching a hungry mouth - they have no capacity to perceive it. echo takes its input from the command line, not from a pipe.
    – cas
    Mar 15, 2016 at 11:16

3 Answers 3


Shell pipe operator | makes standard output for a command the standard input for the next command, without creating an intermediate file.

You can find detailed information explained in a simple way in the following sources:

  • I would expect from echo dump | echo two to get two dump in output, but is only two. Why?
    – andrej
    Mar 15, 2016 at 8:21
  • 3
    @andrej that's because echo doesn't act on its input; so dump is fed into the second echo's input, which ignores it and outputs two. Mar 15, 2016 at 8:34
  • This is because echo ignores standard input, and dumps command line arguments to standard output. In your example, dump is sent to standard input of the second echo, but gets ignored, hence only two gets printed. To avoid this, you can use xargs to make the second echo read from its std input.
    – assefamaru
    Mar 15, 2016 at 8:35
  • 1
    Teaching xargs this way is a really really bad idea. There are cases where xargs should be used but it's not a beginner command, because there are too many security issues that can be created that way. If you want to run both commands, just run both commands. echo dump; echo two If you don't want the first newline suppress the first newline. echo -n dump; echo two Or just use one command: echo dump two Or do it fancy and use printf: printf '%s %s\n' dump two
    – Wildcard
    Mar 15, 2016 at 8:48
  • 1
    @andrej, it doesn't say it ignores the brightness sensor on your laptop, either, but it does. The command does what is described in the man page—nothing more, nothing less. If it doesn't say in the man page that it does something with the standard input then you shouldn't expect it to. That applies to any command and any man page; they're not "exceptions."
    – Wildcard
    Mar 15, 2016 at 9:43

This command writes the string consisting of the seven characters ’.dump’ followed by a newline character to the sqlite command. (That's 12 bytes in all.)

The sqlite command will fail to understand the instruction and will so write nothing to the target file bacula.sq, reporting Error: incomplete SQL: ’.dump’ to stderr.

Perhaps you meant this instead, which uses single quote characters ' instead of apostrophe marks :

echo '.dump' | sqlite bacula.db > bacula.sq
  • 1
    I wonder why it was exactly 12 bytes. takes 3 bytes! TIL.
    – Alexander
    Mar 15, 2016 at 9:31

| is a pipeline operator in Unix/Linux. It could be used where the output of the first command can be used as input to the second command.

For example:

ls -l | less will show the longlist of your files in the directory. The less command takes the output of ls -l as input and displays the list of files where you scroll up/down and see them.

Not the answer you're looking for? Browse other questions tagged .