• 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: using grep in a do shell script
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: using grep in a do shell script


  • Subject: Re: using grep in a do shell script
  • From: Graham Anderson <email@hidden>
  • Date: Mon, 24 Jan 2005 16:01:37 -0800

this does not quite work...but is it a bit closer ?
many thanks



set my_path to (path to preferences) & "Fonovisa.xml" as string
set thepath to POSIX path of my_path

loadTextFile(thepath)

on loadTextFile(thepath)
try
set thestring to ""
set theScript to ("cat " & "'" & thepath & "'")
set thestring to do shell script theScript
--return thestring
set gimme to do shell script "echo " & thestring & " | tr '\\r' '\\n' | sed -n '/<ram>/{s/.*<ram>\\(.*\\)<\\/ram>.*/\\1/p;}' "
return gimme
on error err
log ("Cat text file error: " & err)
end try
end loadTextFile


On Jan 24, 2005, at 3:26 PM, Gnarlodious wrote:

Entity Graham Anderson spoke thus:

> if I have an xml tag
 > <ram>512</ram> in an xml file...
 > how can I get the '512' out of it

set someText to "
 if I have an xml tag
 <ram>512</ram> in an xml file...
 how can I get the 512 out of it
 this is what I have so far...currently it returns the whole xml file
 just not sure how to do the same with a local file
 3rd day in applescript learning curve...
 many thanks
"

do shell script "echo " & quoted form of someText & " | tr '\\r' '\\n' | sed -n '/<ram>/{s/.*<ram>\\(.*\\)<\\/ram>.*/\\1/p;}' "


-- Gnarlie _______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
email@hidden


This email sent to email@hidden

_______________________________________________ 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: using grep in a do shell script
      • From: Gnarlodious <email@hidden>
    • Re: using grep in a do shell script
      • From: Roger Howard <email@hidden>
References: 
 >Re: using grep in a do shell script (From: Gnarlodious <email@hidden>)

  • Prev by Date: Re: iWork Pages
  • Next by Date: Getting current selection of popup menu
  • Previous by thread: Re: using grep in a do shell script
  • Next by thread: Re: using grep in a do shell script
  • Index(es):
    • Date
    • Thread