How to redirect and pipe in Fish

Redirection

  • To redirect to stdin is similar to Bash:
$ ./a.out > out.txt
  • To redirect stdout is similar to Bash:
$ ./a.out < in.txt
  • To redirect stderr:
$ ./a.out ^ out.txt
  • To redirect both stdout and stderr:
$ ./a.out > out.txt 2>&1

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

Piping

  • To pipe stdout is similar to Bash:
$ ./a.out | less
  • To pipe stderr:
$ ./a.out ^| less
  • To pipe both stdout and stderr:
$ ./a.out 2>&1 | less

Tried with: Fish 2.7.1 and Ubuntu 16.04

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.