RE: Finding lines containing foo in a file
RE: Finding lines containing foo in a file
- Subject: RE: Finding lines containing foo in a file
- From: Doug McNutt <email@hidden>
- Date: Wed, 21 Dec 2005 13:30:41 -0700
At 11:32 -0800 12/21/05, Stockly, Ed wrote:
set itemNumber to "25307"
set filepath to POSIX path of (choose file)
set myShellScript to ("grep " & (itemNumber as string) & " " &
filepath & return) as string
set foundLines to (do shell script myShellScript)
--appleScript error
--do shell script "grep 25307 /CatalogStuff/prdItem.txt
--"
-- "grep: /CatalogStuff/prdItem.txt
--: No such file or directory"
I know the file is there. I know the string I'm looking for
is in the file. I've reduced the shell script to the simplest
possible form.
It's hard to believe that you have the targeted file in the system's
root directory. Are you leaving out a leading "~" symbol?
$HOME/CatalogStuff/prdItem.txt is more likely. Surely choose file
includes the directory - doesn't it? Perhaps it defaults to:
$HOME/Documents/CatalogStuff/prdItem.txt.
The return you're adding will be a Mac line end and it looks as
though it's being treated as a part of the path. Take it out.
Learn about "quoted form of" for passing paths via AppleScript even
though that may not be the problem here.
--
Applescript syntax is like English spelling:
Roughly, but not thoroughly, thought through.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden