Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm paranoid about this, but hopefully it's a simple question:

Is there any difference between

cat file1 | egrep -oP "[Mm]y string" > /home/user/file.txt


cat file1|egrep -oP "[Mm]y string">/home/user/file.txt

i.e., does it matter if I have spaces padding the pipe (|) and redirection (>) characters? I'm really paranoid that having spaces there the spaces will somehow end up in the output file when I don't want that. Can anyone clarify? (Using Ubuntu 12/bash if that matters.)

share|improve this question
The only differences are a) cosmetic and b) convenience when editing command lines in bash - e.g. a "word" is delimited by spaces, so without spaces around | or > then typing Ctrl-W to delete the previous "word" would delete more than you probably wanted. ditto for cursor-movement keystrokes like Esc-f and Esc-b etc. – cas Sep 17 '12 at 5:37
up vote 6 down vote accepted

In the shell command line, unquoted spaces only serve to delimit words during command parsing. They are not passed on, neither in the arguments the command sees nor in the standard input stream.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.