Students occasionally ask me why this doesn’t work:
% mkdir foo | cd foo .script: line 10: cd: foo: No such file or directory
because they think that the pipe symbol (
|) means “and then”.
The pipe symbol means:
% echo -e 'my\ndog\nspot' my dog spot % echo -e 'my\ndog\nspot' | sort dog my spot
If you want to execute one command after another, just do so:
% mkdir foo % cd foo
% mkdir foo; cd foo
Note that using semicolon (
;) is no less typing
than just pressing the Enter key.