Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > Grep question..

Grep question..
Thread Tools
Senior User
Join Date: Jul 2001
Status: Offline
Reply With Quote
Apr 20, 2004, 01:35 PM
 
I have a script that runs in BBedit and it's smaller cousin. But I need it to be a separate app like an apple script app. I know that it uses GREP to do it's work. but I do not know how to make it just use grep without the bbedit program.

Code:
tell application "TextWrangler" activate «event R*chRepl» "^TITLE:.*\\r|^FCM:.*\\r|^M2.*\\r|^\\*.*\\r|^\\n+\\*.*\\r|^\\x1A\\x1A\\x1A\\x1A+.*" given «class Repl»:"", «class FnIn»:text 1 of «class TxtW» 1, «class Opts»:{«class SMod»:«constant SModGrep», «class STop»:true, «class Wrap»:false, «class Rvrs»:false, «class Case»:false, «class Wrds»:false, «class ExSl»:false} «event R*chRepl» "V\\s+|C\\s+|D\\s+|K\\s+|B\\s+" given «class Repl»:"", «class FnIn»:text 1 of «class TxtW» 1, «class Opts»:{«class SMod»:«constant SModGrep», «class STop»:true, «class Wrap»:false, «class Rvrs»:false, «class Case»:false, «class Wrds»:false, «class ExSl»:false} «event R*chRepl» " \\d\\d\\d " given «class Repl»:"", «class FnIn»:text 1 of «class TxtW» 1, «class Opts»:{«class SMod»:«constant SModGrep», «class STop»:true, «class Wrap»:false, «class Rvrs»:false, «class Case»:false, «class Wrds»:false, «class ExSl»:false} «event R*chRepl» " \\([A-Z]\\) " given «class Repl»:"", «class FnIn»:text 1 of «class TxtW» 1, «class Opts»:{«class SMod»:«constant SModGrep», «class STop»:true, «class Wrap»:false, «class Rvrs»:false, «class Case»:false, «class Wrds»:false, «class ExSl»:false} «event R*chRepl» "\\sO\\s" given «class Repl»:"", «class FnIn»:text 1 of «class TxtW» 1, «class Opts»:{«class SMod»:«constant SModGrep», «class STop»:true, «class Wrap»:false, «class Rvrs»:false, «class Case»:false, «class Wrds»:false, «class ExSl»:false} «event R*chRepl» "([:\\d\\d]) ([\\d\\d:])" given «class Repl»:"\\1\\t\\2", «class FnIn»:text 1 of «class TxtW» 1, «class Opts»:{«class SMod»:«constant SModGrep», «class STop»:true, «class Wrap»:false, «class Rvrs»:false, «class Case»:false, «class Wrds»:false, «class ExSl»:false} «event R*chRepl» "( +)" given «class Repl»:"\\t", «class FnIn»:text 1 of «class TxtW» 1, «class Opts»:{«class SMod»:«constant SModGrep», «class STop»:true, «class Wrap»:false, «class Rvrs»:false, «class Case»:false, «class Wrds»:false, «class ExSl»:false} end tell

and the file is this
http://www.aprilcolo.com/oh/plink/mic/edl.EDL.zip
     
Professional Poster
Join Date: Sep 1999
Location: Ottawa, ON, Canada
Status: Offline
Reply With Quote
Apr 20, 2004, 03:27 PM
 
Using the system tools grep or awk will probably do what you want. I think something like awk is what you need if replacing text. The grep tool only searches.
     
Mac Elite
Join Date: Sep 2000
Location: in front of the keyboard
Status: Offline
Reply With Quote
Apr 20, 2004, 03:38 PM
 
sed
signatures are a waste of bandwidth
especially ones with political tripe in them.
     
Mac Elite
Join Date: Oct 1999
Location: San Jose, Ca
Status: Offline
Reply With Quote
Apr 21, 2004, 07:09 PM
 
Perl, definitely a job for perl.
     
loren s  (op)
Senior User
Join Date: Jul 2001
Status: Offline
Reply With Quote
Apr 26, 2004, 10:39 AM
 
I treid a bunch of stuff. But my script will not work.

I need it to use sed I supose. but it needs to open up a file and write a new file beside it in the same folder. Can you help ? Or is there a good link to a perfect apple script tutorial ?
     
loren s  (op)
Senior User
Join Date: Jul 2001
Status: Offline
Reply With Quote
Apr 26, 2004, 08:06 PM
 
When I try
do shell script command at the end of the line it tells me that end tell is no good.

Anyother clue how to ruun it as an app ?
     
loren s  (op)
Senior User
Join Date: Jul 2001
Status: Offline
Reply With Quote
Apr 26, 2004, 08:21 PM
 
a while back someone kindly created this
Code:
cat infile | tr "\r" "\n" | sed -e '/^[0-9]\{4,\}/\!d;s/\([^ ]* [^ ]*\)[A-Z0-9 ]* \(.*\)/\1 \2/' > outfile
but I could never run it for some reason. should it be like ?
Code:
cat filedirty | tr "\r" "\n" | sed -e '/^[0-9]\{4,\}/\!d;s/\([^ ]* [^ ]*\)[A-Z0-9 ]* \(.*\)/\1 \2/' > fileclean
     
loren s  (op)
Senior User
Join Date: Jul 2001
Status: Offline
Reply With Quote
Apr 28, 2004, 03:29 PM
 
Please... ^v^
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 09:09 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2