Page 2 of 2 FirstFirst 12
Results 11 to 17 of 17

Thread: bash script to delete files

  1. #11
    Guest

    Re: bash script to delete files

    I bow to your skillz GnuVince...

  2. #12
    Mentor
    Join Date
    Jun 2001
    Posts
    1,672

    Re: bash script to delete files


    you do not even really need a script, find and rm can do it just fine.

    Code:
    find /home/user -size -1024k -maxdepth 1 -type f -exec rm {} \;
    See, I new it would be simple in bash. Thanks for the effort Vince!

  3. #13
    Guest

    Re: bash script to delete files




    See, I new it would be simple in bash. Thanks for the effort Vince!
    You can't remember that command dude! Use the Python! ;D

  4. #14

    Re: bash script to delete files

    You can't remember that command dude! Use the Python! ;D
    If you made it a bash script, you wouldn't have to remember it.

  5. #15

    Re: bash script to delete files

    Would it be considered a script if it only had one command in it? You could write a BASH script to have it look and remove files with an interface to choose multiple sizes or last accessed time a such. Just an idea. And if the command is really hard to remember, alias it.



    If you made it a bash script, you wouldn't have to remember it.

  6. #16

    Re: bash script to delete files

    Would it be considered a script if it only had one command in it?
    It would be considered a script if you put it in a file and made the file executable.

    And if the command is really hard to remember, alias it.
    That would work too, but sometimes you need to use the command from something that doesn't honor BASH aliases (like mutt), in which case you'd have to make it a script.

  7. #17

    Re: bash script to delete files

    Ok. How does this look?

    #!/bin/bash/
    #Interactive House Cleaning Script
    echo " 1. Delete files from /home/users based on size"
    echo " 2. Delete TMP files."
    read answer
    echo
    case "$answer" in
    1)
    echo ""
    echo "Let's clean house."
    echo ""
    echo -n "Enter the users name:"
    read USER
    echo -n "How large of files you wanting to delete? EXAMPLE, 1024 -"
    read SIZEk
    find /home/$USER -size -$SIZEk -maxdepth 1 -type f -exec rm {} \;
    echo "DONE!"
    clear
    ;;
    2)
    echo ""
    echo "Let's clean house of the TMP files."
    echo -n "Enter the users name:"
    read USER
    find /home/$USER -name "*.tmp" -maxdepth 1 -type f -exec rm {} \;
    find /home/$USER -name "*.TMP" -maxdepth 1 -type f -exec rm {} \;
    echo "DONE!"
    ;;
    esac

Similar Threads

  1. Help with bash script
    By woodson2 in forum Linux - Software, Applications & Programming
    Replies: 5
    Last Post: 12-30-2010, 07:19 PM
  2. Winnt\temp files will not delete
    By ronwolff2001 in forum Windows - General Topics
    Replies: 1
    Last Post: 06-22-2006, 07:28 PM
  3. Bash script
    By linuxuser in forum Programming
    Replies: 1
    Last Post: 09-01-2005, 03:21 PM
  4. Strange problem: Cannot delete files in Linux w/ Win98
    By patpat1212 in forum Linux - Hardware, Networking & Security
    Replies: 1
    Last Post: 03-30-2005, 06:04 AM
  5. Help with bash script
    By tolstoy in forum Programming
    Replies: 5
    Last Post: 05-21-2002, 11:17 AM

Bookmarks

Posting Permissions

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