"Personal thoughts, ramblings, and nonsense from Drew, himself."
While at work, I had a customer ask me how to, one time, delete all the mail in his /home/[account-name]/mail/cur directory.
So, first off, I wanted him to just take a look at that directory, get to know it (figuratively speaking). So I had him run the du command on it; wow, you wouldn’t imaging how much mail was in there!
The actual command I had him run was:
BASH
cd /home/[account-name]/mail/cur
du -h ./
The output was 1.3GB. Yes, that’s right, he had 1.3GB of mail files. Some people are unaware of what exactly the difference is between the /new directory and the /cur. The difference is simply that the /cur directory is full of email messages that the user has already viewed somehow, whether by webmail, Outlook, Thunderbird, etc, they have viewed it, and the mail is now officially not exactly new. The /new directory is a directory that has mail that has not yet been opened by the user yet.
So, the customer asked me a simple question, “How do I go about just deleting this data?”. From a user’s point of view, the command would be:
BASH
cd /home/[account-name]/mail/cur
rm -r ./*
Then the customer would have received the error: /bin/rm: Argument list too long. I have found a workaround though. I have asked a few people around what they use the find command for. All of there answers where pretty much the same, “They help you find files”. That’s all they could really tell me what find does. This isn’t all true. find can help us defeat the /bin/rm: Argument list too long error. So, I had the customer run the following:
BASH
cd /home/[account-name]/mail/cur
find . -name '11*' -exec rm "{}" \;
It worked for him, and it can work for you. Let me dissect this command real quick for you, so that you aren’t completely lost. find is the actual command, followed by a period; this means you are going to be searching the current directory (at this time /home/[account-name]/mail/cur). Next you supply the -name switch to tell the find command that you want the pattern (coming next) to match the name of the file. You then give it a search pattern, and in this case all his files started with eleven (11) and everything after that was different, so the pattern would be 11*; make sure the search pattern is in single quotes. Next you supply the -exec command, which will execute any Linux command you want (as long as it is installed on your system). In this case we used the rm command. The quoted curly braces tell it to run rm on each file that matches the pattern supplied. That’s it. Simple command turns to be a very helpful utility.
Hope this helps someone in the future, as I had to figure it out on my own.
Well last week, I finally got the call that IBM was looking for someone that could do Advanced Support in their AIX department, and they had accepted me as an employee. Great! Finally, a job. It’s not just a job, though, this could be my steping-stop; something to really get me in the door and make something of my life. I have plans for many things in life, but they all lead to one thing, success. Success is the key that unlocks every door to whom I become. So, where am I getting with this? Continue reading Finally, a job.
Ajax AOL/AIM Apache Applications Architecture Career Case Projects CentOS CSS Debian Design File Systems Google Hacks Hardware Humor JavaScript Life Management Movies Networking Open-Standards Personal PHP Programming Registry Samba Security Shell Scripting Software Sys Admin Tech The Notebook Tips UNIX/Linux Virtualization VMWare VPC (MS Virtual PC) Walkthrough Web Apps Windows Work Workaround XHTML XHTML 2.0