per comment #1: more code, less description
Why doesn't this work as expected? ie: i want to :
- ssh to a bunch of remote hosts in a loop (hence the </dev/null)
- check if a setting is present in (the remote) rc.local (with grep)
- if not then add it (with sed)
#!/bin/bash targetHostList=" pizerocam0 pizerocam1 pizerocam2 pizerocam3 " while IFS= read -r targetHost;do [[ -z $targetHost ]] && continue ssh -q $targetHost "[[ -f /etc/rc.local && -z $(grep -o '/usr/bin/tvservice -o' /etc/rc.local) ]] && sudo sed -Ei 's/exit\ 0/\/usr\/bin\/tvservice\ \-o \#\ disable HDMI\n\nexit\ 0/' /etc/rc.local" done<<<"$targetHostList"