LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 09-02-2008, 11:33 AM   #1
Fredde87
Member
 
Registered: Aug 2005
Posts: 158

Rep: Reputation: 30
Bash script: Move files, ignore case


Hi,

I was stupid enough to forget to turn all the letters in the usernames on my email server to lower case when a new user is added.

I now have several hundred customers with a mixture of letters (/home/mail/domain.com/FirstName/) for their maildir.

I am writing a script to copy emails from amavisds quarantine folder to the users Junk folder. However since the addresses I grep from the spam are in different cases then the folder I cant figure out a good way to solve this.

My script is bash based so I have three arrays, one containing the domain, one containing the user and one containing the spam file name. There are no duplicates (FirstName/firstname) when it comes to the folder. Can I get mv to ignore case so that I can do the following "mv spam-1231424534 /home/mail/domain./firstname/.Junk/new" even though the path is actually /home/mail/domain./FirstName/.Junk/new


Thanks!

Fredrik
 
Old 09-02-2008, 11:52 AM   #2
keefaz
Senior Member
 
Registered: Mar 2004
Distribution: Slackware
Posts: 4,341

Rep: Reputation: 73
Maybe like this:
Code:
mv spam-1231424534 /home/mail/domain./[fF]irstname/.[jJ]unk/new
But better to fix the problem at the source (eg convert to lowercase before make the directories)
 
Old 09-02-2008, 01:42 PM   #3
Matir
Moderator
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Ubuntu
Posts: 8,507

Rep: Reputation: 117Reputation: 117
What if you have a user FirstName and a user firstname?

By the RFCs, SUS, etc., it is quite distinct to have two emails that are only different in case. That being said, modern implementations ignore that.

My best bet would be something like:
Code:
USERPATH=`find /home/mail/domain.com -iname '$USERNAME'`
 
Old 09-03-2008, 03:34 AM   #4
Fredde87
Member
 
Registered: Aug 2005
Posts: 158

Original Poster
Rep: Reputation: 30
Quote:
Originally Posted by Matir View Post
What if you have a user FirstName and a user firstname?

By the RFCs, SUS, etc., it is quite distinct to have two emails that are only different in case. That being said, modern implementations ignore that.

My best bet would be something like:
Code:
USERPATH=`find /home/mail/domain.com -iname '$USERNAME'`
Thanks that worked perfectly!

I should never had a user called firstname if there is one already called FirstName. I have set my add form which adds the users to my mysql database to make them all lowercase from now one. It was only at first when I was migrating existing customers over where I copied and pasted a big batch from a list I had been provided with.

Thanks!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to tell bash to move files to another folder? hq4ever Linux - Newbie 10 12-30-2010 03:15 AM
BASH script with case ( mandriva ) hellreaper Programming 3 02-19-2008 07:36 AM
After a piece of software/a bash script to mass-move files [Fedora Core 6] Alux Linux - Desktop 3 11-23-2006 02:33 PM
Any arguement that can be used with 'ls' command to ignore case? davidas Linux - Newbie 5 02-26-2006 04:46 AM
Script to Move files jain_rajesh Linux - Newbie 1 10-15-2004 08:53 AM


All times are GMT -5. The time now is 10:36 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration