Re: Extracting text from an Retrospect Log
Re: Extracting text from an Retrospect Log
- Subject: Re: Extracting text from an Retrospect Log
- From: Michael Slomski <email@hidden>
- Date: Tue, 14 Mar 2006 02:30:52 +0100
- Thread-topic: Extracting text from an Retrospect Log
Title: Re: Extracting text from an Retrospect Log
Hello Gnarlie,
am 14.03.2006 1:18 Uhr, Gnarlodious at email@hidden schrieb:
> The OP might consider a command like this:
>
> do shell script "tr '\\r' '\\n' < '/tmp/Operations Log' | sed -n
> '/Retrospect/,${H;/Retrospect/h;${g;p;};}' "
>
> This has 3 advantages. It pipes the translated into sed so it is only one
> line, it will not error in case there is no occurrence of the regex in the
> file, and it only launches one process.
:-( This isn’t doing anything. At least I don’t recognise it... Perhaps ist better to go to bed (it’s already 2 in the morning here in Germany). Just before your xxx was coming in, I ended with the following script which could of corse optimized:
tell application "Finder"
set filePath to quoted form of (POSIX path of "Library:Preferences:Retrospect:Operations Log")
-- translate Mac to UNIX
--do shell script "tr '\\r' '\\n' < " & filePath & " > /tmp/Retrospect.txt"
do shell script "tr '\\r' '\\n' < " & filePath & " > /tmp/tempRetroLog1"
set someRegex to "\\\\]Retrospect\\\\$\\\\["
do shell script "sed -n \"`sed -n '/" & someRegex & "/=' /tmp/tempRetroLog1 | tail -1`,\\$p\" /tmp/tempRetroLog1 >/tmp/tempRetroLastBackupLog"
do shell script "rm /tmp/tempRetroLog1"
--set someRegex to "s/\\$\\[..\\]//g"-- replace $[ 2 chars ]
set someRegex to "s/\\$\\[40\\]/>/g" --replace $[40] with >
do shell script "sed '" & someRegex & "' /tmp/tempRetroLastBackupLog >/tmp/tempRetroLastBackupLog2"
do shell script "rm /tmp/tempRetroLastBackupLog"
set someRegex to "s/\\$\\[.*\\]//g" --replace $[ anything ] with nothing
do shell script "sed '" & someRegex & "' /tmp/tempRetroLastBackupLog2 >/tmp/tempRetroLastBackupLog3"
do shell script "rm /tmp/tempRetroLastBackupLog2"
end tell
Now I have the nearly perfect file. It needs a few temporary files and first and only occurence or the word “Retrospect is also replaced, but... nobody is perfect, at least at this time.
so long so far tomorrow is also a day
by
Michael
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden