основываясь на ответе cbz, вы можете выполнить его команду с помощью appleScript с некоторыми манипуляциями
-- choose afile you could also set this to a variable
set infile to choose file
--lets find out where the file lives so we know where to save the output to
tell application "Finder" to set outpath to quoted form of POSIX path of (container of infile as text)
-- convert the path of file to something shell can understand
set infile to quoted form of POSIX path of infile
--add file name to outpth
set outfile to outpath & "parsed_text.txt"
--put it all together and go, note I rearrange the command so that it will generate the results to a new file
do shell script "sed -e 's,.com/.*$,.com,gw " & outfile & "' " & infile