Applescript:删除文本文件中的重复项
我有一个我创建的 .txt 文件,我正在尝试删除某些重复的文本行。
我给这个文件起的名字是 today.txt,它位于我的桌面上,它包含一个 NYtimes Today's Paper 的 URL 列表。但是,通过解析 html 文件,我收到了几个重复的 url,如下所示:
http://www.nytimes.com/2012/07/06/education/no-child-left-behind-whittled-down-under-obama.html
http://www.nytimes.com/2012/07/06/business/global/markets-look-to-europes-central-bank-for-action.html
http://www.nytimes.com/2012/07/06/business/global/markets-look-to-europes-central-bank-for-action.html
http://www.nytimes.com/2012/07/06/nyregion/3-children-killed-in-long-island-boating-accident.html
http://www.nytimes.com/2012/07/06/nyregion/3-children-killed-in-long-island-boating-accident.html
http://www.nytimes.com/2012/07/06/world/americas/earthquake-relief-where-haiti-wasnt-broken.html
http://www.nytimes.com/2012/07/06/world/americas/earthquake-relief-where-haiti-wasnt-broken.html
http://www.nytimes.com/2012/07/06/us/politics/journal-critique-of-romney-shows-murdoch-doubt-on-candidacy.html
http://www.nytimes.com/2012/07/06/us/politics/journal-critique-of-romney-shows-murdoch-doubt-on-candidacy.html
http://www.nytimes.com/2012/07/06/technology/at-hacker-hostels-living-on-the-cheap-and-dreaming-of-digital-glory.html
http://www.nytimes.com/2012/07/06/technology/at-hacker-hostels-living-on-the-cheap-and-dreaming-of-digital-glory.html
我一直在尝试通过 Applescript 中的do shell 脚本删除重复项,但我无法使其工作。这是我的代码:
set delDups to do shell script "sort /Users/paolob/Desktop/today.txt | uniq -u"
return delDups
所以我的问题是:如何删除today.txt文件中的重复项,然后将结果保存到同一个today.txt文件中
任何帮助将不胜感激。先感谢您。
编辑
如果实际上 shell 脚本或您建议的任何重复删除器直接在 Applescript 编辑器中读取文本,然后将新文本设置为 *new_text* 变量,这将更加经济和快捷。