The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

how to grep mail ids

Discussion in 'E-mail Discussions' started by crazyaboutlinux, Apr 20, 2009.

  1. crazyaboutlinux

    crazyaboutlinux Well-Known Member

    Joined:
    Nov 3, 2007
    Messages:
    938
    Likes Received:
    0
    Trophy Points:
    16
  2. SKiran

    SKiran Registered

    Joined:
    Mar 11, 2009
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    grep "test@" /var/log/exim_mainlog
     
  3. crazyaboutlinux

    crazyaboutlinux Well-Known Member

    Joined:
    Nov 3, 2007
    Messages:
    938
    Likes Received:
    0
    Trophy Points:
    16
    Hi Kiran

    thanks for this

    but this is showing email log that i don't want

    i just want list of email ids
     
  4. cPanelDavidG

    cPanelDavidG Technical Product Specialist

    Joined:
    Nov 29, 2006
    Messages:
    11,279
    Likes Received:
    8
    Trophy Points:
    38
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    You could build a shell script that loops through all the cPanel users and greps against the mail directories which are formatted as:

    /home/USERNAME/mail/DOMAIN/EMAILUSER

    Where /home is the home directory
    USERNAME is the cPanel user's username
    EMAILUSER@DOMAIN is the email address

    Note, there are also symbolic links in /home/USERNAME/mail to the above paths that are .EMAILUSER@DOMAIN (note the . at the start of the folder name)
     
  5. tuxicans

    tuxicans Active Member

    Joined:
    Oct 16, 2008
    Messages:
    38
    Likes Received:
    0
    Trophy Points:
    6
    Hi,

    If you have few accounts only then the following script should be enough.

    cat /home/*/etc/*.*/passwd|grep -i test
     
  6. crazyaboutlinux

    crazyaboutlinux Well-Known Member

    Joined:
    Nov 3, 2007
    Messages:
    938
    Likes Received:
    0
    Trophy Points:
    16
    Hi Tuxicans

    This is really really really nice .

    now suppose i want to delete any email account from the result which i got as below {e.g RED MARKED}

    test:x:32183:32184::/home/abc/mail/abc.com/test:/usr/local/cpanel/bin/noshell
    test:x:32013:32015::/home/def/mail/def.com/test:/usr/local/cpanel/bin/noshell
    test:x:32199:32201::/home/xyz/mail/xyz.org/test:/usr/local/cpanel/bin/noshell



    then which command to be used ???


    Thanks again !
     
    #6 crazyaboutlinux, Apr 21, 2009
    Last edited: Apr 21, 2009
  7. crazyaboutlinux

    crazyaboutlinux Well-Known Member

    Joined:
    Nov 3, 2007
    Messages:
    938
    Likes Received:
    0
    Trophy Points:
    16
    Hi David,


    Tuxicans has given fantastic command & no need to built a shell script.

    however i also want to learn how to create shell script
    (e.g which extension , path to save newly built script , script name )
     
  8. cPanelDavidG

    cPanelDavidG Technical Product Specialist

    Joined:
    Nov 29, 2006
    Messages:
    11,279
    Likes Received:
    8
    Trophy Points:
    38
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    You can build shell scripts in a variety of languages. One common method of building shell scripts is using what's known as "Bash Scripting" - you can learn more about Bash on Wikipedia at: http://en.wikipedia.org/wiki/Bash. There are some links to websites that teach Bash Scripting at the bottom of the page.

    Another common language used for building shell scripts is Perl. You can usually find a book on Perl at a local library, but you can find links to some online tutorials on the bottom of the Wikipedia article on Perl: http://en.wikipedia.org/wiki/Perl
     
Loading...

Share This Page