Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Delete scrip[t that moves files to a thrash directory

Status
Not open for further replies.

rajangupta2387

Programmer
Aug 29, 2012
2
0
0
NL
Can anybody help me in writing a script which does the following;

- the script moves files passed in the argument to /backup/BACKUP_EL603/TRASH/
- the script accepts wildcards
- the script displays the number of files moved using the following format:

empty line
<x> files have been moved to /backup/BACKUP_EL603/TRASH/
empty line

- the script accepts the word TRASH as an argument: in this case, it deleted all files older than 2 weeks present in the TRASH directory
- the script requires at least 1 argument; if no argument is supplied the following message needs to be displayed:

empty line
Usage: <script_name> file
empty line
ex: del my_dummy_file.txt
empty line

- the script can be called from any location (without using the full path)
- possible name for the script: del

During the testing phase the behavior of the script needs to be checked also on directories and soft links.
 
Seems like homework for me ...
what have you tried so far and where in your code are you stuck ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Hi,

I am attaching what i have done. The problem that i am facing is as follows;
i have to completely eradicate the use of rm command from unix. So i have to create an ALIAS to rm and its wildcard options in UNIX in order to move files to THRASH directory and not deleting the files.

What i have already acieved:
1. delete the files with regex and tar them and keep in THRASH directory.(named after the timestamp)
2. THRASH directory cleaning every two weeks.

difficulties:
1. A file A is thrashed on day X.
2. Same file is again thrashed on the day X after some time. -> check to identify that file is already thrashed and to be thrahsed again but then generated as a seperate file.

Attached is the functionality that is already implemented.

Your help is really appreciated.

Thanks in advance

Rajan
 
 http://www.mediafire.com/?k3jpydzpz6nksz2
I think you mean "trash" (as in "rubbish") and not "thrash" (as in "beat repeatedly"). :)

Annihilannic
[small]tgmlify - code syntax highlighting for your tek-tips posts[/small]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top