About bash script. I can't understand this script. Could you please help me understand this script?

su - fred <<! >/dev/null 2>&1

# su: invoke process by substitute user

# fred: username

2 Answers

  • 2 months ago
  • 3 months ago

    The <<! inputs a "!" to the program as an option; that inverts the success/fail result status from the program.

    The rest of the line makes it "silent", with nothing displayed.

    > is redirect, the standard output is redirected to a file or device.

    /dev/null is a standardised "fake device" that ignores anything sent to it.

    2>&1 redirects the standard error output (stream 2) to the same destination as the standard output (stream 1), eg. to /dev/null

Still have questions? Get answers by asking now.