You are not logged in.

#1 2010-10-14 18:41:33

ddmao
Member
Registered: 2010-10-14
Posts: 1

Shell script help

What do you think would be the easiest way to write this script? Python?

Write a script to search the directory tree, starting from the directory given as first parameter, for
files with names that match a pattern given as second parameter and a size greater than or equal
to the value passed as the third parameter. For example,
$ mish /home *mov 1000k

would return all files from the /home directory that end with " mov" (movie mpeg4) and
are larger than or equal to 1 MB. As indicated, it should be possible to use * as a wildcard in the
file name. The shell script will save a log in /tmp/size.txt with information (accumulated and
sorted by file size) of the files found including at least (one line per file) name, path, size,
ownership, date.

From the files found, the script will move to a directory (protected from reading, writing and
execution, except for "root") those belonging to local users (except "root") and that exceed in 3
KByte the size indicated in the third parameter. These files will be stored under /tmp/username
for each user individually (e.g. all files belonging to the user "john" will be stored in the
directory /tmp/john/ ). The script will send an email to each user informing of the files that have
been moved by the administrator.

Finally, the script will schedule a task to be executed 48 hours later. This task will delete all the
files that were moved to /tmp/username (see description above). Note that if the script is run in
two consecutive days, on the third day it should only delete the files from the first run, but NOT
from the second one (which will be deleted on the fourth day).

Offline

#2 2010-10-14 18:59:46

drcouzelis
Member
From: Connecticut, USA
Registered: 2009-11-09
Posts: 4,092
Website

Re: Shell script help

That depends. How good are you at Python?

Offline

#3 2010-10-14 19:08:26

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,424
Website

Re: Shell script help

Please read the Forum Etiquette and don't ask for help with homework:
http://wiki.archlinux.org/index.php/For … e#Homework

Closing


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

Board footer

Powered by FluxBB