Thanks! And thanks for the links. (One can never read the bash man page carefully enough...)
On 11/17/20 12:00 PM, Moshe M. Katz wrote: > `$-` means the options in your current shell. > > * `h` = hashall > * `i` = interactive > * `m` = monitor > * `B` = braceexpand > * `C` = noclobber > * `H` = histexpand > > `${-#*i}` means: > > * `-` = Take the shell options > * `#` = remove the leading match from the parameter > * `*i` = the pattern to search for > > So this takes the string "himBCH", finds the prefix "hi", and removes it. > > It looks like the goal is to only do these operations if the script is > running non-interactively, such as in a cron job, since I assume the > letters are always in the same order. > > Useful bash resources for this kind of thing: > > * > https://www.gnu.org/software/bash/manual/html_node/Shell-Parameter-Expansion.html > * https://www.gnu.org/software/bash/manual/html_node/Pattern-Matching.html > * https://tldp.org/LDP/abs/html/options.html > > > Moshe > > -- > Moshe Katz > mmk...@umd.edu <mailto:mmk...@umd.edu> > (301) 867-3732 > > <http://stackexchange.com/users/440421> > > > On Tue, Nov 17, 2020 at 9:05 AM Judah Milgram <milg...@cgpp.com > <mailto:milg...@cgpp.com>> wrote: > > I mean: for i in file1 file2... > (not f) > > > On 11/17/20 9:00 AM, Judah Milgram wrote: > > I've combed the man page to the best of my ability and can't > figure out > > this snippet from a bash script: > > > > for f in file1 file2.... do > > if [ "${-#*i}" = "$-" ]; then do stuff... > > done > > > > What are those two expansions? They expand consistently to mBCH and > > himBCH which rings a bell somewhere but my lockdown-addled brain just > > can't place it. > > > > thanks... > > Judah > > > > > > > -- > Judah Milgram > milg...@cgpp.com <mailto:milg...@cgpp.com> > 301-257-7069 > > You received this email because you are subscribed to the UM Linux > User's Group (UM-LINUX) mailing list. If you would like to > unsubscribe from this list, simply send an email to > lists...@listserv.umd.edu <mailto:lists...@listserv.umd.edu> with > the message signoff UM-LINUX in the body. > > You received this email because you are subscribed to the UM Linux > User's Group (UM-LINUX) mailing list. If you would like to unsubscribe > from this list, simply send an email to lists...@listserv.umd.edu with > the message signoff UM-LINUX in the body. -- Judah Milgram milg...@cgpp.com 301-257-7069 You received this email because you are subscribed to the UM Linux User's Group (UM-LINUX) mailing list. If you would like to unsubscribe from this list, simply send an email to lists...@listserv.umd.edu with the message signoff UM-LINUX in the body.