Simple string searching in a text file

Get help. Get answers. Let others lend you a hand.

Moderator: Mr_Noodle

Re: Simple string searching in a text file Tue Aug 07, 2012 5:25 pm • by a_freyer
Yes but instead of $1 you need to put the file name.
a_freyer
 
Posts: 631
Joined: Tue Sep 30, 2008 9:21 am
Location: Colorado

Re: Simple string searching in a text file Tue Aug 07, 2012 5:36 pm • by DBCooper
That makes more sense. I figured the $1 was a variable local to the embedded script. Here's what I get:

Code: Select all
$ [ $(grep -ci biking 2012-08-06-144807.TCX) -gt 0 ]
$ echo $?
0

Does that help? I've got my 1's and 0's all mixed up at this point. :cry:
DBCooper
 
Posts: 20
Joined: Tue Aug 07, 2012 2:37 am

Re: Simple string searching in a text file Tue Aug 07, 2012 5:41 pm • by a_freyer
That's the exact correct exit status of zero. This should be working in hazel. Are you sure that this isn't working in Hazel?
a_freyer
 
Posts: 631
Joined: Tue Sep 30, 2008 9:21 am
Location: Colorado

Re: Simple string searching in a text file Tue Aug 07, 2012 5:52 pm • by DBCooper
Good question. At first I was using the "Reveal in Finder" option to see if the rule was running successfully. Then I switched to copying the files to the Desktop. Neither has been happened. Here's what I have at this point.

Image

Image

Everything seems to match yours. I was pointed to a folder which is a symlink. I've even changed that and am pointing to the original folder now.
DBCooper
 
Posts: 20
Joined: Tue Aug 07, 2012 2:37 am

Re: Simple string searching in a text file Tue Aug 07, 2012 6:02 pm • by a_freyer
Anything interesting in console?
a_freyer
 
Posts: 631
Joined: Tue Sep 30, 2008 9:21 am
Location: Colorado

Re: Simple string searching in a text file Tue Aug 07, 2012 6:09 pm • by DBCooper
Just one of these for each file.

Code: Select all
2012-08-07 17:06:13.469 hazelworker[5658] DEBUG: 2012-08-06-144807.txt: Did not match any rules.
DBCooper
 
Posts: 20
Joined: Tue Aug 07, 2012 2:37 am

Re: Simple string searching in a text file Tue Aug 07, 2012 6:16 pm • by a_freyer
Well this doesn't make any sense to me, haha. Our rules are duplicate, our files are duplicate, mine works and yours doesn't.

Perhaps you can send a copy of your rules? Maybe there is a slight different that a second pair of eyes could find?

I'm about to go through security at an airport, so I won't be able to reply for an hour or so.
a_freyer
 
Posts: 631
Joined: Tue Sep 30, 2008 9:21 am
Location: Colorado

Re: Simple string searching in a text file Tue Aug 07, 2012 6:25 pm • by DBCooper
By the way, I tried rebooting. No luck. :? I thought that was supposed to fix all computing woes?
DBCooper
 
Posts: 20
Joined: Tue Aug 07, 2012 2:37 am

Re: Simple string searching in a text file Tue Aug 07, 2012 9:29 pm • by a_freyer
Hmm..... Now I'm really not sure what to tell you. Your rule works perfectly fine for me without modification (OP PM'd me his rule).

Image
a_freyer
 
Posts: 631
Joined: Tue Sep 30, 2008 9:21 am
Location: Colorado

Re: Simple string searching in a text file Tue Aug 07, 2012 11:55 pm • by DBCooper
Well, this is mystery, isn't it? I'm going to delete and reinstall Hazel. Maybe I'll get lucky.
DBCooper
 
Posts: 20
Joined: Tue Aug 07, 2012 2:37 am

Re: Simple string searching in a text file Wed Aug 08, 2012 12:06 am • by DBCooper
OK, fresh install. Is it normal to see this window every time you open the Hazel preferences? I was seeing it before too.

Image

I had to click through this dialog four times the last time I opened Hazel. Could this be part of the problem?
Last edited by DBCooper on Wed Aug 08, 2012 1:30 am, edited 1 time in total.
DBCooper
 
Posts: 20
Joined: Tue Aug 07, 2012 2:37 am

Re: Simple string searching in a text file Wed Aug 08, 2012 1:20 am • by a_freyer
No, that's not normal. Are you an admin user?
a_freyer
 
Posts: 631
Joined: Tue Sep 30, 2008 9:21 am
Location: Colorado

Re: Simple string searching in a text file Wed Aug 08, 2012 1:32 am • by DBCooper
Yes, I'm an admin. See above. Sometimes I have to click through it multiple times.
DBCooper
 
Posts: 20
Joined: Tue Aug 07, 2012 2:37 am

Re: Simple string searching in a text file Wed Aug 08, 2012 3:30 pm • by Mr_Noodle
Regarding that alert, see this thread.

As for why the rule isn't working, I suggest breaking up that script into multiple lines so you can see the values at each point.
Mr_Noodle
Site Admin
 
Posts: 11865
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: Simple string searching in a text file Wed Aug 08, 2012 6:21 pm • by DBCooper
Are you suggesting that I break up this code?

Code: Select all
exit $([ $(grep -ci biking $1) -gt 0 ])

How would I see the intermediate results? Does it get logged if I have debugging turned on?
DBCooper
 
Posts: 20
Joined: Tue Aug 07, 2012 2:37 am

PreviousNext

Return to Support