Results 1 to 6 of 6

Thread: Search command

  1. #1
    Join Date
    Apr 2005
    Location
    Tinterweb
    Posts
    555

    Question Search command

    Hi,
    Does anyone know how to search a server for extensions (exe, mp3) then delete them.
    Using ssh or software

    Thanks

  2. #2
    Join Date
    Jul 2001
    Location
    Glasgow, Scotland
    Posts
    129
    find / -type f -name '*mp3' -exec rm {} \;
    find / -type f -name '*exe' -exec rm {} \;

    Use this with caution, alternatively use rm -i to be prompted on every file before removal.
    I take no liability, but it should work... :p
    My development blog - (un)Interesting codesnippets and the occational code-related rant!

  3. #3
    Join Date
    Apr 2005
    Location
    Tinterweb
    Posts
    555
    Hi,
    Thanks, I ran that command and i noticed that it scans the whole server so I could delete files that are needed, is there a command that can just scan a particular directory (/home)?

    Thanks

  4. #4
    man find
    the second argument is the path where you want to find files. For exapmple:
    find /home -type f -name '*exe' -exec rm {} \;

  5. #5
    Join Date
    Apr 2005
    Location
    Tinterweb
    Posts
    555

    Question Search

    Is there a way for searching multiple extension say .mp3 and .wma at the same time?

    Thanks

  6. #6
    Join Date
    Jul 2005
    Posts
    56
    on BSD you would do something like this:
    find -E . -iregex '.*\.(mp3|wma)$' -exec rm {} \;

    might be slightly different if you're using Linux
    the "." is the current directory, you could just replace that with a path of your choice

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •