Removing files with containg certain string of text

Posted on 2006-04-04
Last Modified: 2013-12-27
Hi All,

Currently I have a mail queue being building up and we need to delete all messages being sent to a certain domain name.  What is the best command to recurrsively go through each file and whenever it finds that specific domain name it either delets or move it to a tmp folder?

Many Thanks!
Question by:n-generation
    1 Comment
    LVL 38

    Accepted Solution

    you can do someting like:

    cd /var/spool/mqueue
    for i in `grep -l "" *`  ; do
        mv $i /path-to/mytmpdir

    # delete them !
    cd /var/spool/mqueue
    rm `grep -l "" *`  

    Featured Post

    Highfive Gives IT Their Time Back

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    Hello fellow BSD lovers, I've created a patch process for patching openjdk6 for BSD (FreeBSD specifically), although I tried to keep all BSD versions in mind when creating my patch. Welcome to OpenJDK6 on BSD First let me start with a little …
    Why Shell Scripting? Shell scripting is a powerful method of accessing UNIX systems and it is very flexible. Shell scripts are required when we want to execute a sequence of commands in Unix flavored operating systems. “Shell” is the command line i…
    Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
    In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    13 Experts available now in Live!

    Get 1:1 Help Now