Command file for moving emails


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Command file for moving emails
# 1  
Old 11-28-2008
Command file for moving emails

hey guys. I'm trying to create a command file that moves my emails to a specified folder according to a keyword that is in the subject.

like move emails with "hey" in the subject to a folder that exists in my mail folder named "hey". how do I go about that? thanx.
# 2  
Old 11-29-2008
anyone?
# 3  
Old 11-30-2008
Quote:
Originally Posted by ~samantha89~
anyone?
Please read the rules (4): do not 'bump up' questions if they are not answered promptly!
# 4  
Old 11-30-2008
This should work for you.

mv $(grep -l hey inbox/*) hey/


Found this from google.... Smilie
# 5  
Old 12-01-2008
okay, thanks. one question though, which "hey" is the subject line and which "hey" is the output folder? so that I know how to use the command with other emails.
# 6  
Old 12-01-2008
how does grep -l specify the subject line of the email files as "hey", or whatever I happen to use. I'm trying to move email files based upon the content of the subject line for the email. much like a procmailrc file would, only as a command line or command file.
# 7  
Old 12-02-2008
hey, can't you use something like this for your command file?

#!/bin/bash
MAILDIR="/var/spool/mail/firstname.lastname"
TEXT="hey"
DESTDIR="$HOME/Mail/hey"
find "$MAILDIR" -type f | while read N
do
cat "$N" | grep -q "$TEXT"
if [ $? == 0 ]; then
mv "$N" "$DESTDIR"
fi
done
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Mail command does not work for Distribution List emails

mail works for my personal email address mailx -s "Alert" mymail@mycomp.com<results.txt mail fails for the Teams Distribution List (copied from outlook) mailx -s "Alert" #My-Team@mycomp.com<results.txt This was the first problem. The second problem is if I have the subject line... (4 Replies)
Discussion started by: mohtashims
4 Replies

2. UNIX for Dummies Questions & Answers

Moving lines of file to command line

I have a file in which each line is the name of another file. Is there a way to serve them to the command line? For example, if the file contains file1.txt file2.txt file3.txt ... file9.txt is there a way to insert them in the command as a batch? If I ran a command like grep... (4 Replies)
Discussion started by: wbport
4 Replies

3. Shell Programming and Scripting

issue while moving files using find command

Hi Friends, I'm facinf issue while moving large files using find command.I've a scenario like i've to move one day older files from one directory to anothe directory.I'm using the below command. find $src_dir -name error -prune -o -type f -mtime +1 -exec mv {} $dest_dir \; some times... (1 Reply)
Discussion started by: mail2mura
1 Replies

4. Shell Programming and Scripting

extracting emails from a file

i have a large html file that has emails like something@domain.com and somethingdomain.com how can i print the emails? its fine if duplicates show up and it doesnt need to save into a file or anything, just whatever is the easiest way to make some basic code for this thanks! :) (2 Replies)
Discussion started by: vanessafan99
2 Replies

5. Shell Programming and Scripting

Issue while moving files using find command

Hi All, I'm facing this below error when I move files using find command....Please help out...... $ find /home/aa/ab -mtime +90 -type f -exec mv -f {} /home/aa/ab/ac \; mv: 0653-405 /home/aa/ab/ac/MP_060520111245.csv and /home/aa/ab/ac/MP_060520111245.csv are identical. mv: 0653-405... (2 Replies)
Discussion started by: HemaV
2 Replies

6. Shell Programming and Scripting

Moving 100K file to another folder using 1 command

Hi, I need to move 1000s of files from one folder to another. Actually there are 100K+ files. Source dir : source1 Target dir : target1 Now if try cp or mv commands I am getting an error message : Argument List too long. I tried to do it by the time the files are created in the source... (6 Replies)
Discussion started by: unx100
6 Replies

7. Shell Programming and Scripting

moving files alone using mv command??

Is there a way to move the files ALONE from one dir to another dir? In my source dir,I have files as well as directories.I want to move the files alone to another dir and the directories should remain undisturbed. If I use mv * < target dir> ,then the directories also moved. Any... (4 Replies)
Discussion started by: prasperl
4 Replies

8. Shell Programming and Scripting

Moving file using test command

My process creates file like abc.20090427.txt i.e abc.date.txt next time when my process it has to detect if any previous "abc" exist. If exist then move to archive and create a new abc file. I am using test command but it doesnt allow wild card. if ] then mv abc.*.txt... (7 Replies)
Discussion started by: pinnacle
7 Replies

9. Shell Programming and Scripting

moving files after ls -lt command

Can you please tell me how to find a file in a directory and then if it exists i need to place it in a different folder? I have to use "ls -lt" command I mean this command is something existing one . can you please tell me how i set the directory path. Like dir1/dir2/filename.csv to... (8 Replies)
Discussion started by: pochaman
8 Replies

10. Shell Programming and Scripting

extract bulk emails into a single flat file

Hello Can someone guide me how to extract bulk emails into a single flat file ? We receive mails (approx 1K daily ). I want the contents of the emails for 'current date' to be dumped into one single text file. Please help. (1 Reply)
Discussion started by: Amruta Pitkar
1 Replies
Login or Register to Ask a Question