Si te sientes más cómodo con Applescript puedes ejecutar el shell script de @Lauri Ranta con el siguiente AppleScript :
do shell script "grep -vxf master.txt today.txt > today2.txt; cat master.txt today2.txt > master2.txt"
Si no te queda claro, he hecho un AppleScript incluyendo el shell script de @Lauri Ranta.
He aquí cómo crear paso a paso una aplicación AppleScript que fusionará la lista de hoy con una lista maestra sin duplicados
. Las rutas a las listas maestras y de hoy se guardan entre lanzamientos o se preguntan si no se encuentran/definen.
. Tras la fusión, la lista de hoy se borra
1. Abrir el editor AppleScript
2. Pegue el código siguiente
\-- 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. Exportar como aplicación
Menú Archivo > Exportar > Formato de archivo : Aplicación
4. Haga una copia de seguridad de sus listas.
5. Prueba la aplicación que acabas de crear