<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Oct 19, 2015, at 1:45 AM, Jeremy Laidman <<a href="mailto:jlaidman@rebel-it.com.au" class="">jlaidman@rebel-it.com.au</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">Jason<div class=""><br class=""></div><div class="">Nice work.</div><div class=""><br class=""></div><div class="">A suggestion, to avoid setting oIFS and then having to clean up again later:</div><div class=""><br class=""></div><font face="monospace, monospace" class="">FILESYSTEMS=`mount | egrep -v '[\( ](nobrowse|read-only)[ ,\)]' | sed  's/^.* on \(.*\) (.*)$/\1/'`</font><div class=""><font face="monospace, monospace" class="">echo "[df]"<br class="">(IFS=$'\n'</font></div><div class=""><font face="monospace, monospace" class="">set $FILESYSTEMS<br class="">df -PH $1; shift<br class="">while test $# -gt 0<br class="">do<br class="">  df -PH $1 | tail -1 | sed 's/\([^ ]\) \([^ ]\)/\1_\2/g'<br class="">  shift<br class="">done) | column -t -s " " | sed -e 's!Mounted *on!Mounted on!'</font><div class=""><br class=""></div><div class="">By moving "IFS=..." and "set $FILESYSTEMS" into the parens, the scope of the variable change is kept within the parens, thus auto-cleanup.</div></div></div></div></blockquote><div><br class=""></div><div><br class=""></div>Great idea.  I also had to change the inode test a bit since originally I didn't restore IFS until after both df and inode tests ran.<br class=""><div><br class=""></div><div><br class=""></div><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class=""><div class="">A second suggestion is to replace the egrep+sed pipeline with a single sed command, such as:</div><div class=""><br class=""></div><div class=""><font face="monospace, monospace" class="">FILESYSTEMS=`mount | sed '/[\( ](nobrowse|read-only)[ ,\)]/d;s/^.* on \(.*\) (.*$/\1/'`</font><br class=""></div><div class=""><br class=""></div><div class="">This saves an extra process fork/exec.  The "/<regexp>/d" operation for sed will delete matching lines, emulating "egrep -v".</div></div></div></div></blockquote><div><br class=""></div><div><br class=""></div><div>I'm all for saving forks/execs.  To make your example work, though, I had to call sed with '-E' to enable extended regular expressions and change which parens I escaped in the substitution expression.  This updated patch also skips AFS mounts.</div><div><br class=""></div><div>I appreciate your feedback!</div><div>-Jason</div><div><br class=""></div><div><div>--- xymonclient-darwin.sh.orig    2015-10-17 18:19:14.000000000 -0500</div><div>+++ xymonclient-darwin.sh  2015-10-19 11:41:39.000000000 -0500</div><div>@@ -26,22 +26,24 @@</div><div> echo "[who]"</div><div> who</div><div><br class=""></div><div>-FILESYSTEMS=`mount | grep -v nobrowse | awk '{print $3}'`</div><div>+FILESYSTEMS=`mount | sed -E '/[\( ](nobrowse|afs|read-only)[ ,\)]/d;s/^.* on (.*) \(.*$/\1/'`</div><div> echo "[df]"</div><div>-set $FILESYSTEMS</div><div>-(df -H $1; shift</div><div>+(IFS=$'\n'</div><div>+ set $FILESYSTEMS</div><div>+ df -PH $1; shift</div><div>  while test $# -gt 0</div><div>  do</div><div>-   df -H $1 | tail -1</div><div>+   df -PH $1 | tail -1 | sed 's/\([^ ]\) \([^ ]\)/\1_\2/g'</div><div>    shift</div><div>  done) | column -t -s " " | sed -e 's!Mounted *on!Mounted on!'</div><div><br class=""></div><div> echo "[inode]"</div><div>-set $FILESYSTEMS</div><div>-(df -i $1; shift</div><div>+(IFS=$'\n'</div><div>+ set $FILESYSTEMS</div><div>+ df -i $1; shift</div><div>  while test $# -gt 0</div><div>  do</div><div>-   df -H $1 | tail -1</div><div>+   df -H $1 | tail -1 | sed 's/\([^0123456789% ]\) \([^ ]\)/\1_\2/g'</div><div>    shift</div><div>  done) | awk '</div><div> NR<2{printf "%-20s %10s %10s %10s %10s %s\n", $1, "itotal", $6, $7, $8, $9}</div><div class=""><br class=""></div></div><div><br class=""></div></div><div apple-content-edited="true" class="">
-- <br class="">Jason White<br class=""><a href="mailto:jdwhite@menelos.com" class="">jdwhite@menelos.com</a>

</div>
<br class=""></body></html>