If you know /bin/bash is the right location, then use /bin/bash. If not, let 'env' find it. -- William
On Wed, Mar 01, 2017 at 04:09:11AM -0500, Bob Jonkman via talk wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > Hi Scott: Why do this: > > #!/usr/bin/env bash > > and not the usual > > #! /bin/bash > > ??? > > - --Bob. > > > On 2017-02-24 11:21 PM, Scott Elcomb via talk wrote: > > On Fri, Feb 24, 2017 at 9:24 PM, Stewart C. Russell via talk > > <[email protected]> wrote: > >> On 2017-02-20 12:47 AM, Aruna Hewapathirane wrote: > >>> > >>> Hi Stewart, you could just |watch| the file listing (adjusting > >>> n seconds to whatever is suitable) > >>> > >>> |watch --differences -n 10 ls -l </path/to/shared/dir>| > >> > >> I hadn't heard of watch before, so thanks! watch *started* to > >> work really well, but then went into a terminal sulk after the FS > >> disappeared during a scan, and refused to show any updates. It's > >> also an interactive program, so doesn't pipe or notify changes in > >> any useful way. > >> > >> I suspect I'll just have to go with William Park's suggestion of > >> using rsync to a local folder that I have more control over. I > >> still have to correct for the scanner FS's wandering clock, but > >> that's less important. > > > > Here's a quick and dirty bash script similar to the watch command; > > adjust to taste. :-) > > > > [- watchdir.sh snippet starts -] > > > > #!/usr/bin/env bash # # USAGE # watchdir.sh <rate> <path> # > > > > > > # Determine our sampling rate WATCHRATE=${1} > > > > if [[ "" = "${WATCHRATE}" ]]; then WATCHRATE=10 fi > > > > # Determine our watch directory WATCHDIR=${2} > > > > if [[ "" = "${WATCHDIR}" ]]; then WATCHDIR="." fi > > > > # Describe what we're doing echo "Watching ${WATCHDIR} every > > ${WATCHRATE}s:" > > > > # Render a side-by-side comparison with last snapshot of our > > directory # note: assumes at least one snapshot already exists > > function sample_watchdir { cp .current .previous date > .current ls > > -l ${WATCHDIR} >> .current echo "" diff -y .current .previous } > > > > # Begin watching date > .current ls -l ${WATCHDIR} >> .current > > sample_watchdir > > > > # Every WATCHRATE seconds, make the current file listing our > > previous # listing, take a fresh look at WATCHDIR and compare the > > changes while sleep ${WATCHRATE}; do sample_watchdir done > > > > [- watchdir.sh snippet ends -] > > > > - -- > > > - -- > Bob Jonkman <[email protected]> Phone: +1-519-635-9413 > SOBAC Microcomputer Services http://sobac.com/sobac/ > Software --- Office & Business Automation --- Consulting > GnuPG Fngrprnt:04F7 742B 8F54 C40A E115 26C2 B912 89B0 D2CC E5EA > > > > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v2 > Comment: Ensure confidentiality, authenticity, non-repudiability > > iEYEARECAAYFAli2j7UACgkQuRKJsNLM5eobKQCfUCOoqN2ncebZcc7mBA2BIYl1 > pXIAoI4Ce2/FSphaU28ADlvybH1rbyQE > =MXyH > -----END PGP SIGNATURE----- > --- > Talk Mailing List > [email protected] > https://gtalug.org/mailman/listinfo/talk --- Talk Mailing List [email protected] https://gtalug.org/mailman/listinfo/talk
