• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
RE: Finding lines containing foo in a file
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


References: 
 >RE: Finding lines containing foo in a file (From: "Stockly, Ed" <email@hidden>)

  • Prev by Date: RE: Finding lines containing foo in a file
  • Next by Date: Re: Finding lines containing foo in a file
  • Previous by thread: RE: Finding lines containing foo in a file
  • Next by thread: Re: Finding lines containing foo in a file
  • Index(es):
    • Date
    • Thread