Home > front end >  Please explain this shell script using <&
Please explain this shell script using <&

Time:06-11

Can you explain what this script means?

2<<< hello <&2 cat

If I run this shell script, it spits hello. But cannot understand what it means.

Can you please explain one by one?

Many thanks.

CodePudding user response:

see https://www.gnu.org/software/bash/manual/bash.html 3.6.7 and 3.6.8

  1. 2<<< hello puts a string hello to stderr;
  2. <&2 redirect stderr to stdin
  3. cat is a program which receive the string hello from stdin and print out
  • Related