-1

find /home -name .bashrc > list 2>&1

I learn from book that the above command is to redirect the output of find into a file called list including both STDOUT and STDERR. (Particularly, all things in STDOUT will be outputted in front of STDERR.)

And I know that 2 is STDERR, 1 is STDOUT.

But I'm having problem with "parsing" and understanding the > list 2>&1 part? And What is 2>&1?

Cyrus
  • 84,225
  • 14
  • 89
  • 153
Lowson Pan
  • 67
  • 1
  • 5
  • http://www.catonmat.net/blog/bash-one-liners-explained-part-three/ – George Vasiliou Sep 13 '17 at 21:24
  • Send 1 to list and send 2 to where 1 is being send to (also list). Compare with `2>&1 > list` : Send 2 to where 1 is being send to (the console) and send 1 to list. – Walter A Sep 13 '17 at 21:50

1 Answers1

1

> list redirects the command's standard out to the file list.

2>&1 redirects your standard error to standard out. In this case, standard out is the file list, so list will contain all output and errors your find command generates.

Further read: https://www.gnu.org/software/bash/manual/html_node/Redirections.html

hek2mgl
  • 152,036
  • 28
  • 249
  • 266
Mini Me
  • 27
  • 1
  • 1
  • 3