• 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: Shell script and grep
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Shell script and grep


  • Subject: Re: Shell script and grep
  • From: John Delacour <email@hidden>
  • Date: Sun, 9 Feb 2003 01:04:38 +0000
  • Mac-eudora-version: 6.0a5

At 5:18 pm -0600 8/2/03, Christopher Stone wrote:

Can a shell scripted grep routine handle an AppleScript variables for input and output?. Looking over the Man page for grep it looks to me as though it requires a *file* for input and output.


Hello Chris,

"... By default, grep prints the matching lines", so you don't need a pathname for output. If you omit the input file it will read lines from STDIN as:

bash-2.05a$ grep 'A'
any
Any
Any
all
All
All
^C
bash-2.05a$

(Only lines with capital A are echoed)


set f to "/usr/share/misc/zipcodes"
do shell script "grep 90210 " & f
display dialog result


set f to "" & (path to "cusr") & "junk"
set fpos to quoted form of POSIX path of f
set nl to ASCII character 10
set s to "all" & nl & "the" & nl & "king's" & nl & "horses"
open for access file f with write permission
write s to file f
close access file f
do shell script "grep k " & fpos
display dialog result
do shell script "grep -Hn k " & fpos
display dialog result

Was that the question?

JD
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.

References: 
 >Record sorting routine (From: "Jerry Podhajsky" <email@hidden>)
 >Shell script and grep (From: Christopher Stone <email@hidden>)

  • Prev by Date: Problems with Network Setup Scripting...continued
  • Next by Date: Re: Shell script and grep
  • Previous by thread: Shell script and grep
  • Next by thread: Re: Shell script and grep
  • Index(es):
    • Date
    • Thread