[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Whitespace problem with bash script for Icedove



On 2011-07-25 20:07, Bill M wrote:
> Hi folks,
> 
> I'm piecing together a small script to remove duplicate messages from
> various directories in Icedove. By default the files are stored in a
> directory called 'Local Folders' - with the space - and this seems to be
> creating a problem for bash. I can both cd to "Local Folders" and cd to
> Local\ Folders from the command line but within the script it's a
> different story. Bash refuses to recognize "Local Folders" as a
> directory and breaks at the whitespace. Here's the script and the error
> output. Any help appreciated.
> 
>     bill
> 
> #! /bin/bash
> 
> # A script to remove duplicate messages
> 
> FILES=/home/bill/.icedove/qjimvr85.default/Mail/Local\
> Folders/2-Personal.sbd/*
> # or "/home/bill/.icedove/qjimvr85.default/Mail/Local
> Folders/2-Personal.sbd/*"
> 
> for i in $FILES
> do
>         mv "$i" ""$i".saved"
>         formail -D 65536 .msgid.cache -s < ""$i".saved" > "$i"
> done
> 
> mv: cannot stat `/home/bill/.icedove/qjimvr85.default/Mail/Local': No
> such file or directory
> ./mailscript: line 10:
> /home/bill/.icedove/qjimvr85.default/Mail/Local.saved: No such file or
> directory
> mv: cannot stat `Folders/2-Personal.sbd/*': No such file or directory
> ./mailscript: line 10: Folders/2-Personal.sbd/*.saved: No such file or
> directory

Hi Bill

Not sure about your Bash script, but 2 months ago I had the same problem
of removing duplicate messages from Thunderbird/Icedove directory tree
and crafted this: http://people.eisenbits.com/~stf/fsd/mboxgrep-perl/ .

Maybe this will be of some help to you, or maybe you will find a bug or
fix the documentation. :-)

mboxgrep-perl comes with no warranty, of course. Backup all your files
before using it.

mboxgrep-perl.pl 0.1 (2011-05-28)

Copyright (C) 2011 Stanislaw Findeisen <stf at eisenbits.com>
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/>
This is free software: you are free to change and redistribute it.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

Usage:
  mboxgrep-perl-0.1.pl [OPTION]...

DESCRIPTION

mboxgrep-perl is a very simple mbox file parser. Features include:
* ability to grep on e-mail headers using regular expressions
* ability to filter out duplicate messages.

Each e-mail message encountered on input is processed once and classified
either as a match or not-match. Matching messages are printed out on
standard output. They can also be deleted from input files.

Using --dup you can filter out duplicate messages. There are 4 different
ways
to define when 2 messages are equal.

OPTIONS

Input control

--source
    mbox file to parse. If this parameter is not specified, standard input
    is read. If this parameter is a directory, it is being read recursively.

E-mail matching

--equiv
    Message identity (equivalence relation) definition. Use 'message-id' for
    Message-ID header fields, 'identity' for binary identity (i.e. hashes
    over whole message) or 'content' for hashes over several fields (i.e.:
    Message-ID, Date, From, To, Cc, Subject, body prefix, body suffix).

    By default, all e-mail messages are considered different to each other.

    Note: not every e-mail message has Message-ID field. If this parameter
    is set to 'message-id' then all such messages will be considered
identical
    (and a warning will be printed on standard error).

    Note: message equivalence has precedence over regular expression
    matching, i.e. if 2 messages are equivalent to each other and one of
    them matches the regex while the other does not, it is unspecified
    which one of them will be considered a match.

--expr
    Perl-compatible regular expression to match the e-mail header against.
    If this parameter is not specified, the expression is considered empty
    and is satisfied by every e-mail message.

    THIS IS A SECURITY HOLE (the expression is passed as-is to Perl's qr//).

-i
    The regular expression specified with --expr is case-insensitive.

--dup
    In order to match, the message must be a duplicate (in processing
order),
    i.e. it must have been preceeded by some other, equivalent message
    (see --equiv).

-v
    Invert match, i.e. match messages that *do not* satisfy --expr *or are
    not* a duplicate (if --dup is specified).

Output control

--del
    Delete matching e-mail messages from input file(s).
    You'd better make a backup first!

--tmpDir
    Temporary directory to use.

-q
    Quiet mode: do not output any e-mails (just parse the file and report
    the count of matching e-mail messages).

--qq
    Be even more quiet: suppress debug messages. This implies -q.

Miscellaneous

--help
    Print this help message.

-w
    By default, mboxgrep-perl uses SHA-256 hashes. Use this option for MD5
    instead. This is weaker but may be faster.

BUGS

    This software was written on purpose and is not tested very well. Bug
    reports, comments, feature requests etc. are welcome:
    bug-report AT eisenbits.com .

-- 
http://people.eisenbits.com/~stf/
http://www.eisenbits.com/

OpenPGP: E3D9 C030 88F5 D254 434C  6683 17DD 22A0 8A3B 5CC0


Reply to: