• 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: has <email@hidden>
  • Date: Wed, 21 Dec 2005 20:23:53 +0000

Ed Stockly wrote:

>--appleScript error
>--do shell script "grep 25307 /CatalogStuff/prdItem.txt
>--"
>--		"grep: /CatalogStuff/prdItem.txt
>--: No such file or directory"
>[...]
>	What am I missing?

set filepath to quoted form of POSIX path of (choose file)

In this case, 'grep' is failing because you're giving it the string "/CatalogStuff/prdItem.txt\r" as its path argument (note the return character on the end).

Remember, Unix uses linefeeds, not carriage returns; if you use a CR where you should be using a LF, bad things happen. But regardless, you should ALWAYS USE THE QUOTED FORM when composing arbitrary AS strings as command arguments in a shell script. If you don't understand why this is so important, you're not safe to be using the command line in the first place.

Oh, and go file a feature request for AppleScript to provide a built-in 'linefeed' constant; I'm not surprised folk get caught out using the semi-obsolete 'return' constant in shell scripts when it's not at all apparent there's an alternative. Meantime, define your own when you need it:

property linefeed : ASCII character 10

HTH

has
--
http://freespace.virgin.net/hamish.sanderson/
 _______________________________________________
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

  • Follow-Ups:
    • Re: Finding lines containing foo in a file
      • From: Gnarlodious <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