[S.Toms]
How can I test to see if a particular file contains a particular string anywhere within it, for example, I want to see if the filename contains .lock as the suffix.
Hello. I think the following might work (from memory, untested): if grep -s 'STRING' FILE >/dev/null; then ACTIONS_IF_FOUND else ACTIONS_IF_NOT_FOUND fi -- 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/
On 25 Jun 2000, [ISO-8859-1] François Pinard wrote: fp> [S.Toms] fp> fp> > How can I test to see if a particular file contains a particular string fp> > anywhere within it, for example, I want to see if the filename contains fp> > .lock as the suffix. fp> fp> Hello. I think the following might work (from memory, untested): fp> fp> fp> if grep -s 'STRING' FILE >/dev/null; then fp> ACTIONS_IF_FOUND fp> else fp> ACTIONS_IF_NOT_FOUND fp> fi fp> Actually, I'm looking for a way to check the filename, not the file contents, for example, I have the following being passed into the script /home/skull/mail/Mailing Lists/SuSE List and I want to check to see if there is a "SuSE List.lock" within that above string, I've tried the following which doesn't seem to work if [ "$FILE" != "*.lock" ]; then Basically, what it comes down to is I have a script that checks my mailing lists boxes and if they are empty and havn't been accessed in over 5 min, it will pass the name of the list to a routine, that checks to see if a lock file exists on it (from procmail) if not, it will delete it. Thus, nolonger showing the empty mailbox so I don't have to keep checkign if there are messages in it. fp> -- S.Toms - tomas@primenet.com - www.primenet.com/~tomas SuSE Linux v6.3+ - Kernel 2.2.14 -- 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/
Hi, On Sun, Jun 25 2000 at 09:45 -0700, S.Toms wrote:
Actually, I'm looking for a way to check the filename, not the file contents, for example, I have the following being passed into the script /home/skull/mail/Mailing Lists/SuSE List
and I want to check to see if there is a "SuSE List.lock" within that above string, I've tried the following which doesn't seem to work
if [ "$FILE" != "*.lock" ]; then
if echo "$FILE" |egrep -q "\.lock$"; then do_something fi hould do the trick. Ciao, Stefan -- 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/
"S.Toms" wrote:
On 25 Jun 2000, [ISO-8859-1] François Pinard wrote:
fp> [S.Toms] fp> fp> > How can I test to see if a particular file contains a particular string fp> > anywhere within it, for example, I want to see if the filename contains fp> > .lock as the suffix. fp> fp> Hello. I think the following might work (from memory, untested): fp> fp> fp> if grep -s 'STRING' FILE >/dev/null; then fp> ACTIONS_IF_FOUND fp> else fp> ACTIONS_IF_NOT_FOUND fp> fi fp>
Actually, I'm looking for a way to check the filename, not the file contents, for example, I have the following being passed into the script /home/skull/mail/Mailing Lists/SuSE List
and I want to check to see if there is a "SuSE List.lock" within that above string, I've tried the following which doesn't seem to work
if [ "$FILE" != "*.lock" ]; then
-- if [ -n "`echo $FILE | grep .lock`" ]; then echo "Suspect detected!"; fi -- N -- 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/
participants (4)
-
mcmxc@freemail.gr
-
pinard@iro.umontreal.ca
-
stefan.troeger@wirtschaft.tu-chemnitz.de
-
tomas@primenet.com