Hello everybody. Actually I would like to ask you who can I make delete commend by shell script to delete some files from anywhere in my director and send it to specific place but whit the PATH because if want to restore it will return to the original place which I delete it from (As recycle pan in windows). To be honest with you I do not have experience in Unix commend so please help me. thanks
What options you have depend greatly on what version of UNIX you have and which shell you are using.
In order to move deleted files to a faux recycle bin, you're going to need to store more than just the files there. You'll need to have some kind of config file or a .ini file for each deleted file that tells UNIX where it came from and when it was deleted. You also will have to find a naming convention so that files deleted that have the same name, but came from different directories don't overwrite each other.
Another option would be to keep the original directory structure where the file came form within your recycle-bin directory. However, this could get difficult to maintain and will require you to parse the directory structure where the file was originally so that you can create the identical structure in your recycle-bin.
Its possible there is some free-ware utility that does this for you, but I have not heard of one.
Hopefully, this gives you some ideas about how you might accomplish what you are asking.
Which asks you confirmation before deleting the file, so there you should decide.
2. Use GNOME or KDE to delete.
Simple like the windows OS, if you use GUI, then the deleted files will be moved to Trash ( Recycle bin there ), from where you can restore.
3. For command line: As suggested earlier, it is very difficult to maintain all the meta data, and original file and so on.
So if you have deleted a wrongly, you have lot of tools to restore it. ( but it is of not 100% recovery anyway. )
4. What i do ?
I will ask my sysadmin to restore my file ( they have 30 days incremental backup -- so no worry at all ).., if i wrongly deleted a file at my work !! -- but nothing to do if i do it in my laptop....
Thank for comments, but as I wrote I have little Unix background and what I wanted as homework also i will hand in on the last of this week so as you know I don’t have long time to cover all commends and I am worry about that. So if you can write any code I will try to understand it and do it.
Hi
I use this commend to move any files to backup file
mv $* $HOME/backup/.
But if I want to remove files with their paths because if I want to restore it from (backup file) to the original place I think will need it also if I have the same file name in the deferent place will give me error when I remove it.
The purpose from this work how I can remove files and restore these again.
thanks
Hello,
When I am deleleting some file that time I am moving that file to backup
directory and when I say restore then its showing me the backupdirectory
path and file with index..Ex..if i delete 3 files then restore will shoe me:
:0:/backup/somedeletedfile
:1:/backup/somedeletedfile10
:2:/backup/somedeletedfile20
My concern is if someone will say restore 1...then i want to restore
somedeletedfile20 to its original location i.e. the location from where it is
deleted
Maybe replace the delete command (rm) by reversible command (tar)
In short:
Replace the rm command by a deliberately tailored "tar" command.
Whenever you type "rm file" it will actually execute "tar Recycle-bin/file.tar file" - which will move the file into the recycle bin, and maintain the file's original path.
You can achieve this replacement by the "alias" command.
A few points to take into account:
1. will work if "rm" used with full path, but not if relative path is used. (can be worked around, but will require some thinking and looking up man pages. Maybe even coockoig up a few lines of a script)
2. The command line options of "rm" and of "tar" are different. Need to deal with that.
Another approach:
Alias the "rm" command, so that it creates a folder under the recycleBin. This folder will have the file's name. The deleted file will be moved Into this folder, and another little text file will be created in the folder to contain the path of the file"
Restoring will be simply moving the file into the path that can be taken form the little text file.
The points to notice mentioned above, apply here too with slight modifications.
Hi All,
Do you have any sample script,
- auto get file from SFTP remote server and delete file in remove server after downloaded.
- only download specify filename
- auto upload file from local to SFTP remote server and delete local folder file after uploaded
- only upload specify filename
... (3 Replies)
Hi
My directory structure is as below.
dir1, dir2, dir3
I have the list of files to be deleted in the below path as below.
/staging/retain_for_2years/Cleanup/log $ ls -lrt
total 0
drwxr-xr-x 2 nobody nobody 256 Mar 01 16:15 01-MAR-2015_SPDBS2
drwxr-xr-x 2 root ... (2 Replies)
Friends, I had written a small script to delete files from deletefiles.txt file. However, I want to add one more piece to script, so as to check if the file(file abc) which was already deleted earlier exists in 'deletefiles.txt' file, script should comment out that "file abc doesnt exist". Can... (5 Replies)
I 'm trying to write a unix script with delete statement on DB2 tables based on the date.The issue I have is that I need to delete the records on 2 tables but only one table have date field and based on another key I have to delete the related records.
Table 1:-
DateID
KeyColumn
Field 1... (5 Replies)
ENVIROMENT
Linux: Fedora Core release 1 (Yarrow)
iPlanet: iPlanet-WebServer-Enterprise/6.0SP1
Log Path: /usr/iplanet/servers/https-company/logs
I have iPlanet log rotation enabled rotating files on a daily basis.
The rotated logs are NOT compressed & are taking up too much space.
I... (7 Replies)
Hi,
I want to delete files that are older than 60 days.... i need to execute the script in 7 differnt folders.... i can run the script in crontab to regularly check....
I am struck @ finding out how the file is 60 days old or not...
Can u please help me on this?
Thanks,
NithZ (6 Replies)
Hi,
I have a requirement like,
I need to create the directory with date and time stap (i.e YYYYMMDDHMS) every day end need to delete the old directories which is 12 months old. I have tested with following script
cd /export/home/sbeeravo/; find . -type d -mtime +365 -exec rm -rf {} \;
... (2 Replies)
Hi
I need a script that will remove the contents out of a common named folder on our server and all its contents.
We have folder called temp which resides within several different folders and i need to delete the contents at a set time in the night
thanks
Treds (7 Replies)
Hi User,
I have a text file with a lot of customer records (over 10,000). Each record contained one field called "charge" and it must start with some space (each record may have 15 space, 17 spece, 9 space,etc, then start with <charge> and end with </charge>, in between is a value.
How can I... (3 Replies)
I have a local linux machine in which the files are dumped by a remote ubuntu server. If the process in remote server has any problem then empty files are created in local machine. Is there any way using perl script to check if the empty files are being created and delete them and then run a shell... (2 Replies)