~pcwiz Posted July 4, 2008 Share Posted July 4, 2008 OK I have this plist here: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>PciRoot(0x0)/Pci(0x1,0x0)/Pci(0x0,0x0)</key> <dict> <key>@0,compatible</key> <string>NVDA,NVMac</string> <key>@0,device_type</key> <string>display</string> <key>@0,name</key> <string>NVDA,Display-A</string> <key>@1,compatible</key> <string>NVDA,NVMac</string> <key>@1,device_type</key> <string>display</string> <key>@1,name</key> <string>NVDA,Display-B</string> <key>@2,#adress-cells</key> <string>0x01000000</string> <key>@2,#size-cells</key> <string>0x00000000</string> <key>@2,compatible</key> <string>NVDA,sensor-parent</string> <key>@2,device_type</key> <string>NVDA,gpu-diode</string> <key>@2,hwctrl-params-version</key> <string>0x02000000</string> <key>@2,hwsensor-params-version</key> <string>0x02000000</string> <key>@2,name</key> <string>sensor-parent</string> <key>@2,reg</key> <string>0x02000000</string> <key>NVCAP</key> <data> BAAAAAAAAwAMAAAAAAAABwAAAAA= </data> <key>NVPM</key> <data> AQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA== </data> <key>device_type</key> <string>NVDA,GeForce</string> <key>model</key> <string>NVIDIA GeForce 7600 GS EFI</string> <key>name</key> <string>NVDA,Parent</string> <key>rom-revision</key> <string>0x32323033</string> </dict> </dict> </plist> How would I use AppleScript to replace the "PciRoot(0x0)/Pci(0x1,0x0)/Pci(0x0,0x0)" key with "PciRoot(0x1)/Pci(0x1,0x0)/Pci(0x0,0x0)"? Thanks Link to comment https://www.insanelymac.com/forum/topic/113979-some-applescript-help-please/ Share on other sites More sharing options...
x64tj Posted March 13, 2009 Share Posted March 13, 2009 You can "do shell script" and use sed or awk to find/replace. The only problem is that they can be picky with special characters like ( ) or / (which you have... lol). Most of the time you can get around it by putting a \ in front of them. Here's a couple of things to try: If you want to do it with a single line, try: echo "My source string" | awk '{ gsub("source", "new"); print $1 }' or by an entire file (which is what I think you want to do): sed 's/findthis/replacewiththis/g' 'source file' You kinda have to play around with it. I used the sed method to do a find and replace of /etc/hostconfig to disable spotlight as a post-restoration script for older G3 iMacs. Just remember to respect reserved unix characters like a \ would be written as a \\ or a return would be \n (think C++ or printf with PHP). Good luck, hope this helps! Link to comment https://www.insanelymac.com/forum/topic/113979-some-applescript-help-please/#findComment-1105798 Share on other sites More sharing options...
Recommended Posts