Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I'm quite new to Linux but still need to get the job done. My email server is running out of disk space.I need to delete some emails direct from the server and my first attempt is to delete emails dedicated to allstaff@mycompanyemail
I've grep the absalute path of those emails and store them into another files like this
grep –r allstaff@mycompanyemail* > /tmp/allstaff
Can anybody give the idea on how can i delete those emails by using the information in /tmp/allstaff. Should you have any other way is also can.
That command will not display anything. How if I want to display what file being deleted and the total size of deleted files? I may want to confirm that it will not delete the wrong file
a/b/filename: for <allstaff@mycompanydomain>; Tue, 6 Mar 2007 12:05:41 +0800
To select a/b/filename part from this, use the command
"cut -d':' -f1"
The pipe sequence then becomes: cat | cut | xargs where the cat may be replaced with the grep or find commands.
To make sure that you don't delete anything by accident, you could add the -i option (interactive mode) to rm, which makes it ask for confirmation before actually deleting anything.
You could also use a harmless command, like echo or ls -l instead of the rm at the end of your pipe sequence.
An all-in-one solution could look something like this:
Code:
cat your_file |cut -d':' -f1 > some_filelist #instead of cat, you can also use the grep or find already posted
for i in `cat some_filelist`; do
ls -l ${i}; #get the filesize
rm -i ${i}; #delete it, but with confirmation
done;
cat your_file |cut -d':' -f1 > some_filelist #instead of cat, you can also use the grep or find already posted
for i in `cat some_filelist`; do
ls -l ${i}; #get the filesize
rm -i ${i}; #delete it, but with confirmation
done;
Thank you timmeke. It almost solved my problem. However there are few file names with double dot and numbers or characters like this :
a/d/filenamewith':'and'number'or'char':for <allstaff@mycompanydomain>; Tue, 6 Mar 2007 12:05:41 +0800
eg : a/d/fgfg:2,S:To: <allstaff@mycompanydomain>
Actually I don't really know how to use the option for cut command
Maybe you can split up the strings on spaces rather than the colons ("double dots")?
eg use cut -d' ' -f1
-d => delimiter character
-f => cuts out certain fields (that are separated by the delimiter)
Note that "cut" only works on single character delimiters. So if we need to split up your lines on let's say the " To: " string, we'll need to look at "sed" or "awk", rather than "cut".
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.