Find the answer to your Linux question:
Results 1 to 4 of 4
Hi all, I am a newbie on Bash script as well. And How can I actually implement the task below? a. Check the user's storage. If a user storage at ...
  1. #1
    Just Joined!
    Join Date
    Sep 2008
    Posts
    2

    Bash script help!

    Hi all, I am a newbie on Bash script as well. And How can I actually implement the task below?

    a. Check the user's storage. If a user storage at /home/username directory has reached preset storage limit like 100MB, send him an email.

    b. And also shows the files which is larger than 100K at /home/username directory, giving the user an option either to delete it or compress it, then show him the next file.

    c. Write a "safe" delete command script. Filenames passed as command-line arguments to this script are not deleted, but instead gzipped if not already compressed, then moved to a /home/username/trash directory.

    Thanks in advance...

  2. #2
    Linux Guru coopstah13's Avatar
    Join Date
    Nov 2007
    Location
    NH, USA
    Posts
    3,149
    This sounds like a homework assignment to me, which it is against forum rules for us to straight up give answers to questions. Look online for bash tutorials and linux commands to give you those informations.

  3. #3
    Linux Engineer GNU-Fan's Avatar
    Join Date
    Mar 2008
    Posts
    935
    Quote Originally Posted by evios View Post
    a. Check the user's storage. If a user storage at /home/username directory has reached preset storage limit like 100MB, send him an email.
    You could use the du command for the particular home directory with the 's' and 'h' option. Faster than this is to employ quotas, but the filesystem has to be formated in a certain format for this.

    Quote Originally Posted by evios View Post
    b. And also shows the files which is larger than 100K at /home/username directory, giving the user an option either to delete it or compress it, then show him the next file.
    "find /home/username -size +100k" lists all such files.

    Quote Originally Posted by evios View Post
    c. Write a "safe" delete command script. Filenames passed as command-line arguments to this script are not deleted, but instead gzipped if not already compressed, then moved to a /home/username/trash directory.
    You can have aliases for commands via the shell. If the user executes 'rm', a wrapper application is executed instead. This wrapper applies gzip on the file, deletes the original and moves the file to a /home/username/trash directory. The "trash" had better to begin with a dot so that it is not shown in the normal directory listing but is hidden.
    Debian GNU/Linux -- You know you want it.

  4. #4
    Just Joined!
    Join Date
    Sep 2008
    Posts
    2
    Quote Originally Posted by coopstah13 View Post
    This sounds like a homework assignment to me, which it is against forum rules for us to straight up give answers to questions. Look online for bash tutorials and linux commands to give you those informations.
    The first two is used for self practice ... and the last one yeah is coming from my homework. I' d tried half of it but leaving this I can hardly find the solutions else where ...

Posting Permissions

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