Delete Mail Based on Subject Pattern [mail-command]

Clash Royale CLAN TAG#URR8PPP
Is it possible to delete all mail in which the subject matches a regex pattern?
For example, to delete message 1, you do:
d 1
But to delete all mail with subject starting with, say, [SPAM], I can't do:
d -s "^[SPAM].*$"
mail-command
add a comment |
Is it possible to delete all mail in which the subject matches a regex pattern?
For example, to delete message 1, you do:
d 1
But to delete all mail with subject starting with, say, [SPAM], I can't do:
d -s "^[SPAM].*$"
mail-command
1
Can you usemutt? That can match-and-then-delete by pattern.
– thrig
Jan 17 '17 at 18:24
2
Use another mail program, e.g.mutt:Dto delete all messages matching a pattern, and you can more generally and flexible tag messages according to your needs, and then apply some action to them.
– dirkt
Jan 17 '17 at 18:24
@thrig @dirkt Thanks for the suggestion! I will check outmutt.
– nehcsivart
Jan 17 '17 at 18:28
add a comment |
Is it possible to delete all mail in which the subject matches a regex pattern?
For example, to delete message 1, you do:
d 1
But to delete all mail with subject starting with, say, [SPAM], I can't do:
d -s "^[SPAM].*$"
mail-command
Is it possible to delete all mail in which the subject matches a regex pattern?
For example, to delete message 1, you do:
d 1
But to delete all mail with subject starting with, say, [SPAM], I can't do:
d -s "^[SPAM].*$"
mail-command
mail-command
asked Jan 17 '17 at 18:18
nehcsivartnehcsivart
363311
363311
1
Can you usemutt? That can match-and-then-delete by pattern.
– thrig
Jan 17 '17 at 18:24
2
Use another mail program, e.g.mutt:Dto delete all messages matching a pattern, and you can more generally and flexible tag messages according to your needs, and then apply some action to them.
– dirkt
Jan 17 '17 at 18:24
@thrig @dirkt Thanks for the suggestion! I will check outmutt.
– nehcsivart
Jan 17 '17 at 18:28
add a comment |
1
Can you usemutt? That can match-and-then-delete by pattern.
– thrig
Jan 17 '17 at 18:24
2
Use another mail program, e.g.mutt:Dto delete all messages matching a pattern, and you can more generally and flexible tag messages according to your needs, and then apply some action to them.
– dirkt
Jan 17 '17 at 18:24
@thrig @dirkt Thanks for the suggestion! I will check outmutt.
– nehcsivart
Jan 17 '17 at 18:28
1
1
Can you use
mutt? That can match-and-then-delete by pattern.– thrig
Jan 17 '17 at 18:24
Can you use
mutt? That can match-and-then-delete by pattern.– thrig
Jan 17 '17 at 18:24
2
2
Use another mail program, e.g.
mutt: D to delete all messages matching a pattern, and you can more generally and flexible tag messages according to your needs, and then apply some action to them.– dirkt
Jan 17 '17 at 18:24
Use another mail program, e.g.
mutt: D to delete all messages matching a pattern, and you can more generally and flexible tag messages according to your needs, and then apply some action to them.– dirkt
Jan 17 '17 at 18:24
@thrig @dirkt Thanks for the suggestion! I will check out
mutt.– nehcsivart
Jan 17 '17 at 18:28
@thrig @dirkt Thanks for the suggestion! I will check out
mutt.– nehcsivart
Jan 17 '17 at 18:28
add a comment |
3 Answers
3
active
oldest
votes
I am answering this in case anyone comes by the same question.
It does not appear there is any way to do bulk deletion by pattern matching using mail.
An alternative is to use the mutt mail client, which does have such feature:
D [SPAM]
Thanks to @thrig and @dirkt for suggesting the alternative.
Please accept your answer.
– Tripp Kinetics
May 21 '18 at 18:30
1
@TrippKinetics Okay, I have accepted the answer.
– nehcsivart
May 21 '18 at 18:32
add a comment |
According to "man mail" there are plenty of different patterns to specify the messages on which the command like "d" for deletion will work on. For the asked subject line, you can use
(subject string)
All messages that contain string in the Subject: field.
In the mail command you would write:
& d (subject Happy Birthday)
This will delete every mail that has the string "Happy Birthday" in its subject. There are also patterns for other fields and different date related criterions (It was tested with "Heirloom Mail version 12.4 7/29/08.")
add a comment |
I was looking for the same without success, so I decided to try like this:
echo 'f 1-$' | mail -N | grep 'SPAM' | awk 'print $1'
Or print $0 to see the full header to show the mail number with the string 'SPAM'.
So if you think is ok you can delete all of this.
echo 'd #1 #2 #3 ...' | mail -N
Or make a full script.
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f338115%2fdelete-mail-based-on-subject-pattern-mail-command%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
I am answering this in case anyone comes by the same question.
It does not appear there is any way to do bulk deletion by pattern matching using mail.
An alternative is to use the mutt mail client, which does have such feature:
D [SPAM]
Thanks to @thrig and @dirkt for suggesting the alternative.
Please accept your answer.
– Tripp Kinetics
May 21 '18 at 18:30
1
@TrippKinetics Okay, I have accepted the answer.
– nehcsivart
May 21 '18 at 18:32
add a comment |
I am answering this in case anyone comes by the same question.
It does not appear there is any way to do bulk deletion by pattern matching using mail.
An alternative is to use the mutt mail client, which does have such feature:
D [SPAM]
Thanks to @thrig and @dirkt for suggesting the alternative.
Please accept your answer.
– Tripp Kinetics
May 21 '18 at 18:30
1
@TrippKinetics Okay, I have accepted the answer.
– nehcsivart
May 21 '18 at 18:32
add a comment |
I am answering this in case anyone comes by the same question.
It does not appear there is any way to do bulk deletion by pattern matching using mail.
An alternative is to use the mutt mail client, which does have such feature:
D [SPAM]
Thanks to @thrig and @dirkt for suggesting the alternative.
I am answering this in case anyone comes by the same question.
It does not appear there is any way to do bulk deletion by pattern matching using mail.
An alternative is to use the mutt mail client, which does have such feature:
D [SPAM]
Thanks to @thrig and @dirkt for suggesting the alternative.
answered Jan 18 '17 at 22:56
nehcsivartnehcsivart
363311
363311
Please accept your answer.
– Tripp Kinetics
May 21 '18 at 18:30
1
@TrippKinetics Okay, I have accepted the answer.
– nehcsivart
May 21 '18 at 18:32
add a comment |
Please accept your answer.
– Tripp Kinetics
May 21 '18 at 18:30
1
@TrippKinetics Okay, I have accepted the answer.
– nehcsivart
May 21 '18 at 18:32
Please accept your answer.
– Tripp Kinetics
May 21 '18 at 18:30
Please accept your answer.
– Tripp Kinetics
May 21 '18 at 18:30
1
1
@TrippKinetics Okay, I have accepted the answer.
– nehcsivart
May 21 '18 at 18:32
@TrippKinetics Okay, I have accepted the answer.
– nehcsivart
May 21 '18 at 18:32
add a comment |
According to "man mail" there are plenty of different patterns to specify the messages on which the command like "d" for deletion will work on. For the asked subject line, you can use
(subject string)
All messages that contain string in the Subject: field.
In the mail command you would write:
& d (subject Happy Birthday)
This will delete every mail that has the string "Happy Birthday" in its subject. There are also patterns for other fields and different date related criterions (It was tested with "Heirloom Mail version 12.4 7/29/08.")
add a comment |
According to "man mail" there are plenty of different patterns to specify the messages on which the command like "d" for deletion will work on. For the asked subject line, you can use
(subject string)
All messages that contain string in the Subject: field.
In the mail command you would write:
& d (subject Happy Birthday)
This will delete every mail that has the string "Happy Birthday" in its subject. There are also patterns for other fields and different date related criterions (It was tested with "Heirloom Mail version 12.4 7/29/08.")
add a comment |
According to "man mail" there are plenty of different patterns to specify the messages on which the command like "d" for deletion will work on. For the asked subject line, you can use
(subject string)
All messages that contain string in the Subject: field.
In the mail command you would write:
& d (subject Happy Birthday)
This will delete every mail that has the string "Happy Birthday" in its subject. There are also patterns for other fields and different date related criterions (It was tested with "Heirloom Mail version 12.4 7/29/08.")
According to "man mail" there are plenty of different patterns to specify the messages on which the command like "d" for deletion will work on. For the asked subject line, you can use
(subject string)
All messages that contain string in the Subject: field.
In the mail command you would write:
& d (subject Happy Birthday)
This will delete every mail that has the string "Happy Birthday" in its subject. There are also patterns for other fields and different date related criterions (It was tested with "Heirloom Mail version 12.4 7/29/08.")
answered Mar 1 at 10:04
user339460user339460
1
1
add a comment |
add a comment |
I was looking for the same without success, so I decided to try like this:
echo 'f 1-$' | mail -N | grep 'SPAM' | awk 'print $1'
Or print $0 to see the full header to show the mail number with the string 'SPAM'.
So if you think is ok you can delete all of this.
echo 'd #1 #2 #3 ...' | mail -N
Or make a full script.
add a comment |
I was looking for the same without success, so I decided to try like this:
echo 'f 1-$' | mail -N | grep 'SPAM' | awk 'print $1'
Or print $0 to see the full header to show the mail number with the string 'SPAM'.
So if you think is ok you can delete all of this.
echo 'd #1 #2 #3 ...' | mail -N
Or make a full script.
add a comment |
I was looking for the same without success, so I decided to try like this:
echo 'f 1-$' | mail -N | grep 'SPAM' | awk 'print $1'
Or print $0 to see the full header to show the mail number with the string 'SPAM'.
So if you think is ok you can delete all of this.
echo 'd #1 #2 #3 ...' | mail -N
Or make a full script.
I was looking for the same without success, so I decided to try like this:
echo 'f 1-$' | mail -N | grep 'SPAM' | awk 'print $1'
Or print $0 to see the full header to show the mail number with the string 'SPAM'.
So if you think is ok you can delete all of this.
echo 'd #1 #2 #3 ...' | mail -N
Or make a full script.
edited Mar 1 at 20:42
Christopher
10.8k33249
10.8k33249
answered Mar 1 at 20:05
CarlosCarlos
1
1
add a comment |
add a comment |
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f338115%2fdelete-mail-based-on-subject-pattern-mail-command%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
Can you use
mutt? That can match-and-then-delete by pattern.– thrig
Jan 17 '17 at 18:24
2
Use another mail program, e.g.
mutt:Dto delete all messages matching a pattern, and you can more generally and flexible tag messages according to your needs, and then apply some action to them.– dirkt
Jan 17 '17 at 18:24
@thrig @dirkt Thanks for the suggestion! I will check out
mutt.– nehcsivart
Jan 17 '17 at 18:28