Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I find myself needing to do this a few times daily and would love an easier way to do it.

The domain example.com's email is handled by a third party, so the server needs to be told this by listing its domain in /etc/remotedomains.

I then remove the domain from localdomains:

pico /etc/localdomains

Search for "example.com" (being careful not to land on "subdomain.example.com")

Remote "example.com" from /etc/localdomains

Save and close

And place it within remotedomain:

pico /etc/remotedomains

Goto end of file and add "example.com"

Save and close

A way to do this in one command would be great! :)

share|improve this question
    
not one command, but I always do vim -p /etc/localdomains /etc/remotedomains /domain dd gt p :xa. it cuts out the steps of opening closing and saving each file, though I'm pretty sure it could be more optimized. –  xenoterracide Apr 20 '11 at 12:57
add comment

1 Answer

Is example.com on its own line? You could use sed to get rid of it from localdomains (-i tells it to modify the file in-place, ^example.com$ tells it to find an entire line matching example.com, and d tells it to delete that line):

$ sed -i '/^example.com$/d' /etc/localdomains

And then just append it to the end of remotedomains

echo "example.com" >> /etc/remotedomains:

It's technically two commands, but I can't imagine that matters; you can run them on one line by separating them with ;

share|improve this answer
    
Indeed, example.com is on its own line. Thanks for your suggestion :) –  KJBweb Apr 20 '11 at 13:02
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.