Bash 从AppleScript插入sed命令(i)

Bash 从AppleScript插入sed命令(i),bash,sed,applescript,Bash,Sed,Applescript,我如何做到这一点: # Insert a line "heater:M21789" before the line beginning with "fan" $ sed ' /^fan/ i\ heater:M21789 ' order789.txt 取自 在AppleScript中?删除了示例中的txt文件: set theInput to "title: PO for vessel unit1 const. items: fan:F34539 tube:L1245 driller:M454

我如何做到这一点:

# Insert a line "heater:M21789" before the line beginning with "fan"
$ sed '
/^fan/ i\
heater:M21789
' order789.txt
取自


在AppleScript中?

删除了示例中的txt文件:

set theInput to "title:
PO for vessel unit1 const.
items:
fan:F34539
tube:L1245
driller:M4545
Description:
PO signed and verified by factory manager S K Lp
Date: Fri Jan 2 17:26:44 UTC 2009
Author: M Kumar"


set xxx to do shell script "echo " & quoted form of theInput & " | sed '
/^fan/ i\\
heater:M21789
'"

return xxx
或者严格按照您的示例,在~/

do shell script " cd ~; 
sed '
/^fan/ i\\
heater:M21789
' order789.txt"