Se sei più a tuo agio con Applescript puoi eseguire lo script di shell di @Lauri Ranta con il seguente AppleScript:
do shell script "grep -vxf master.txt today.txt > today2.txt; cat master.txt today2.txt > master2.txt"
Se questo non è chiaro per te, ho fatto un AppleScript incluso lo script di shell di @Lauri Ranta.
Ecco come creare passo passo una applicazione AppleScript che unirà l'elenco di oggi a un elenco principale senza duplicati
. Percorsi per padroneggiare e amp; oggi gli elenchi vengono salvati tra i lanci o chiedono se non trovati / definiti
. Dopo l'unione, la lista di oggi viene cancellata
1. Apri l'editor di AppleScript
2. Incolla il seguente codice
-- Merge today list to a master list without duplicates
-- . Paths to master & today lists are saved between launchs or asked if not found/defined
-- . After merge, today list is cleared
-- Path to temporary items folder
property pathToTemp : POSIX path of (path to temporary items)
-- Paths to temporary files
property newAdds_temp : pathToTemp & "mergeLists_new_adds.tmp"
property mergedList_temp : pathToTemp & "mergeLists_merged_list.tmp"
-- Paths to lists
property masterFile : ""
property todayFile : ""
if (masterFile is "") or (not FileExists(masterFile)) then
set todayFile to ""
set masterFile to choose file with prompt "Select the master list :"
end if
if (masterFile is false) then
set todayFile to ""
set masterFile to ""
else
if (todayFile is "") or (not FileExists(todayFile)) then
set todayFile to choose file with prompt "Select the list to add :"
end if
if (todayFile is not false) then
-- Prepare the shell script :
set masterFile_posix to POSIX path of masterFile
set todayFile_posix to POSIX path of todayFile
-- . Save new adds to newAdds_temp
set shellScript to "grep -vxf " & masterFile_posix & " " & todayFile_posix & " > " & newAdds_temp & "; "
-- . Merge master list & new adds to mergedList_temp (and remove newAdds_temp file)
set shellScript to shellScript & "cat " & masterFile_posix & " " & newAdds_temp & " > " & mergedList_temp & "; unlink " & newAdds_temp & "; "
-- . Replace master list by merged mergedList_temp
set shellScript to shellScript & "mv -f " & mergedList_temp & " " & masterFile_posix & "; "
-- . And clean today file
set shellScript to shellScript & "echo \"\" > " & todayFile_posix
-- Execute the generated shell script
do shell script shellScript
-- And display a message
display dialog "Merge done."
end if
end if
-- This function is inspired from Philip Regan answer on :
-- http://stackoverflow.com/questions/3469389/applescript-testing-for-file-existence
on FileExists(theFile)
tell application "System Events" to return (exists theFile)
end FileExists
3. Esporta come applicazione
Menu File > Esporta > FileFormat: applicazione
4. Fai il backup dei tuoi elenchi!
5. Prova l'applicazione appena creata