diff --git a/SC2095.md b/SC2095.md index afea4ed..0fd3a55 100644 --- a/SC2095.md +++ b/SC2095.md @@ -30,6 +30,19 @@ uptime EOF done < hosts.txt ``` +or + +By using a pipe and avoiding the use of the stdin file descriptor, this ensures that commands in the loop are not interfered with. + +```sh +exec 3< hosts.txt +while read -r host +do + ssh "$host" "uptime" +done <&3 +# Close the file descriptor +exec 3<&- +``` ### Rationale: