Code Yarns ‍👨‍💻
Tech BlogPersonal Blog

How to redirect and pipe in Fish

📅 2016-Mar-09 ⬩ ✍️ Ashwin Nanjappa ⬩ 🏷️ fish, pipe, stderr, stdin, stdout ⬩ 📚 Archive

The commands below are for the Fish shell, but most of them work with Bash too.

Redirection

$ ./a.out > out.txt
$ ./a.out < in.txt
$ ./a.out ^ out.txt
$ ./a.out > out.txt 2>&1

Note how the binding of stderr (2) to stdout (1) is placed after the filename.

Piping

$ ./a.out | less
$ ./a.out ^| less
$ ./a.out 2>&1 | less

Reference: Redirections section of the Bash manual.

Tried with: Fish 2.7.1 and Ubuntu 16.04