I have the following script (line numbering is for reference):#!/bin/bash1-  for version in `ls -al ./atk/ | grep ^d | grep -Ev '\.$' | awk -F' ' '{print $8}'`2-      do3-          grep $version ./atk/versions #&>/dev/null <--(first ran with this comment out)4-          if [ $? -ne 0 ]5-              then6-                  printf '%-15s\n' $version7-          fi8-      doneif I run it as is, line 1 will send the following to the screen:(I really don't want this, would like stdout/stderr to go to /dev/null, but more on this later)aaaaa--------bbbbb       |ccccc       |ddddd       |------------ wil be stored in the version variableeeeee       |fffff       |ggggg--------line 2 will look for $version in a versions file that contains the following:12345aaaaa67890ccccc09876fffffif $version is not found in the versions file then print $versions to stdout.output should be the following:bbbbbdddddeeeeeggggghow do I get line 1 to send its output to /dev/null and then have line 3 sendits output back to stdout and stderr? strangely enough, if I uncomment the end of line 3, everything works fine in spiteof the redirection of stdout and stderr to /dev/null!I tried the following:for version in `ls -al ./atk/ | grep ^d &>/dev/null | grep -Ev '\.$' | awk -F' ' '{print $8}'` &>/dev/nullnot only did it suppress the output that I didn't want to see from line 1, but also the output from line 3that I did want to see even after modifying the code as such:for version in `ls -al ./atk/ | grep ^d | grep -Ev '\.$' | awk -F' ' '{print $8}'` &>/dev/null    do        exec &>/dev/tty  ++++++++++++++ trying to reset stdout and stderr back to the origal setting        grep $version ./atk/versions #&>/dev/nullagain, why does line 3 without the comment work when I'm explicitly asking to send all output to /dev/null?
redirect stdout and stderr in a bash script
bash;io redirection