Results 1 to 5 of 5
  1. #1
    Join Date
    Apr 2003
    Posts
    187

    ssh delete all .bak files in directory and sub dirs

    i want to loggin to ssh on a hosting account and run some kind of find and delete comand. Basically ive got 4000 some odd filename.shtml.bak files i need to get rid of from one directory,and all its subs.

    what command could i run to do this?

  2. #2
    Join Date
    Jun 2002
    Posts
    1,172
    rm -rf *.shtml.bak

  3. #3
    Join Date
    Apr 2003
    Posts
    187
    will this only delete files in the current directory and bellow....but not above?

  4. #4
    Join Date
    Jul 2003
    Location
    San Antonio, Tx
    Posts
    1,035
    Then all you need to do is cd into a directory above the main one you want to delete and type:

    rm -rf directorynamehere

    This will remove the entire directory and all it's sub-directories.
    Charnell Lucich
    Community Engagement Manager
    Rackspace Hosting
    http://community.rackspace.com

  5. #5
    Join Date
    May 2003
    Location
    Philadelphia
    Posts
    970
    your best solution would be something along the lines of

    find /path/to/base/dir -name \*.bak -exec rm {} \;

    What this does is basically find any files with the extension of .bak in /path/to/base/dir and any of its sub directories and executes the rm command to delete them.
    http://www.eBoundary.com - Let us help you expand your eBoundaries!
    Fast, Secure and reliable FreeBSD shared, reseller and dedicated hosting.
    FREE Peace of mind with every account!

Posting Permissions

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