returns a single URL line when run manually in Terminal, but returns all lines, or hundreds of lines at least, when run through a run shell script. I thought it was ignoring the argument -F, but it might be something else as the same line without -F also returns just one line when run manually but all lines when done through KM or Applescript.
Actually, it is directly related to KM. See my above solution.
@ppayne, I hope you don't mind that I have revised your topic title to better reflect the question you have asked.
FROM: Grep + Applescript question
TO: How Do I use RegEx (Grep) with AppleScript and Keyboard Maestro?
Providing a succinct, yet descriptive title about your problem/issue will greatly help you attract more experienced users to help solve your problem, and will help future readers find your question, and the solution.
Thanks, this is working pretty smoothly. There's one bit of voodoo though. The display text properly shows me the results I want, indicating that %Variable%Local__MatchedLine% has the correct value. But in the line below, where I try to put the value into the clipboard so I can work with a little more (parse out the URL I need), the value is reverted to its original value (NOT FOUND). Is there any reason why the value of %Variable%Local__MatchedLine% in the Display Text box wouldn't be the same as when other script commands try to work with the value? Speaking the value of %Variable%Local_MatchedLine% immediately after the display results command results in it's original value, not the results I need.
I know you have resolved this, but understanding the issue is also useful.
If grep is behaving differently in response to the -F switch when run from Keyboard Maestro/AppleScript than when run from the Terminal, then my guess is you have two variants of grep installed.
Try doing which grep in the Terminal and see if it is using a different grep instead of the normal /usr/bin/grep, Alternatively, it may be that there are some environment variables that are affecting the behaviour of grep.
Or just carry on with your existing solution, that also works…