[S.Toms]
[François Pinard] fp> [S.Toms]
fp> > How can I test to see if a particular file contains a particular fp> > string anywhere within it, for example, I want to see if the fp> > filename contains .lock as the suffix.
fp> Hello. I think the following might work (from memory, untested): fp> if grep -s 'STRING' FILE >/dev/null; then fp> ACTIONS_IF_FOUND fp> else fp> ACTIONS_IF_NOT_FOUND fp> fi
Actually, I'm looking for a way to check the filename, not the file contents [...]
Oh, I misread your request, sorry. The usual idiom for checking that STRING is contained within FILE as a name is (still from memory, untested): case FILE in *STRING*) ACTIONS_IF_FOUND ;; *) ACTIONS_IF_NOT_FOUND ;; esac You can also find tricks with `expr', `Perl' and surely many other tools, but the above is probably the most portable. I do not have much experience about how to write things when STRING contains embedded spaces, however. -- François Pinard http://www.iro.umontreal.ca/~pinard -- To unsubscribe send e-mail to suse-linux-e-unsubscribe@suse.com For additional commands send e-mail to suse-linux-e-help@suse.com Also check the FAQ at http://www.suse.com/Support/Doku/FAQ/