Skip to content

Instantly share code, notes, and snippets.

@ShawnHuang
Last active January 22, 2017 01:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ShawnHuang/a9ba0bb8a0bccf703b6b17eb705a1d06 to your computer and use it in GitHub Desktop.
Save ShawnHuang/a9ba0bb8a0bccf703b6b17eb705a1d06 to your computer and use it in GitHub Desktop.
stdin
$ find /etc/ -name passwd
find: /etc//cups/certs: Permission denied ->stderr(2)
/etc//pam.d/passwd ->stdout(1)
/etc//passwd

#Redirect stdout

$ find /etc/ -name passwd [1]> file
find: /etc//cups/certs: Permission denied ->stderr(2)
$ cat file
/etc//pam.d/passwd
/etc//passwd
$ find /etc/ -name passwd 2>&1 [1]> file
find: /etc//cups/certs: Permission denied
$ cat file
/etc//pam.d/passwd
/etc//passwd

#Redirect stderr

$ find /etc/ -name passwd 2> file
/etc//pam.d/passwd ->stdout(1)
/etc//passwd
$ cat file
find: /etc//cups/certs: Permission denied

Redirect all

$ find /etc/ -name passwd &> file
$ cat file
find: /etc//cups/certs: Permission denied
/etc//pam.d/passwd
/etc//passwd
$ find /etc/ -name passwd 1>file 2>&1
$ cat file
find: /etc//cups/certs: Permission denied
/etc//pam.d/passwd
/etc//passwd
$ cat file

$ cat < file -> stdin(0)

$ cat - < file

$ cat << EOF
heredoc> test
heredoc> EOF
test

$ cat <<< "test"

$ cat - << EOF
heredoc> test
heredoc> EOF
test

$ cat - <<< "test"

$ cat <(echo "test")

$ cat - <<(echo "test")

$ cat - <(echo "test")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment