Linux shell script delete


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Linux shell script delete
# 1  
Old 11-28-2012
Linux shell script delete

Hi Everyone

I am beginner and I will really appreciate if I receive any help

I want to create linux shell script " delete" that will :
1 create folder "dustbin" if it exists then do nothing
2 move any file that I want to delete from random location into the "dustbin" folder and remember its location for in case I would like to restore it

That's what I now and did so far:

Code:
#!/bin/sh
#this is a Delete script
mkdir -p "DUSTBIN"


Last edited by Scott; 11-28-2012 at 12:30 PM.. Reason: Please use code tags
# 2  
Old 11-28-2012
Code:
#!/bin/sh

echo "please enter the directory name.........."
read dir  #yu have t enter dirrectory as DUSTBIN

 
        if ! [ -d "$dir" ] 
        then
                echo " $dir is not exist, so going to create $dir"
		mkdir -p $dir
       else
               echo "$dir already  exists"
        fi

       

mv *temp $dir

# 3  
Old 11-28-2012
Is this homework?
# 4  
Old 11-28-2012
I am still quite fresh user of linux and I wanted to clean my pc, instead of deleting all files completely I wanted to put some of them that I will think I may need in future into the dust bin Smilie
# 5  
Old 11-30-2012
Better to get a good backup of the OS and all the data files not included in the OS backup. Keep the media safe and remove the files.

If it all goes wrong, restore using your DR procedure if required for an OS file of from your general data media for other files.


You are over complicating things, but do test your OS backup first. Remember that even if you save files to a "dustbin", you have to have a running system to put them back with.




Robin
Liverpool/Blackburn
UK
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Delete db records from shell script

Hello Mates, I would request your help in a shell script, simply I need to delete some matching db table records (rows) to ones in a given file: ------------------------------ #!/bin/bash SQL="delete from numberlist where msidn='';" MYSQL_USER="<your-user>"... (4 Replies)
Discussion started by: EAGL€
4 Replies

2. Shell Programming and Scripting

perl script to check if empty files are created and delete them and run a shell script

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)
Discussion started by: hussa1n
2 Replies

3. UNIX for Dummies Questions & Answers

Shell Script to Delete 1 folder and keep 5

I have situation that I had originally thought would be easily remedied until I learned more about how -mtime actually works. We have one server that collects backups from a number of other servers. The backup server is limited in space (for reasons that predate my employment). The standard... (4 Replies)
Discussion started by: greendevil
4 Replies

4. Shell Programming and Scripting

How do you delete characters in a shell script?

I have printed a character on the screen using a shell script. I want to move that character one space to the left. I have tried moving the cursor to the top left corner of the screen and printing a backspace, like this: tput cup 1 1; printf "\b"; The backspace supposedly deletes the... (5 Replies)
Discussion started by: Ultrix
5 Replies

5. Shell Programming and Scripting

Linux delete script in sub-directory

Under TEMP folder, it have many sub-folder, example"0015,0016,etc" I need to discovery those file which are 2 days ago in this sub-folder , and list out to investigate, at the end delete all file in those sub folder, only keep the emptu directory. Thanks (4 Replies)
Discussion started by: android
4 Replies

6. Shell Programming and Scripting

shell script to partial delete

guys i need some help in writing a shell script, what i am trying to write is a shell script that can delete generated trace files my software usually generated everyday, i will give an example to make it easy to understand root@cms-db # pwd /pcard17/trace root@cms-db # ls -l HSM_VERIF.TRC*... (4 Replies)
Discussion started by: q8devilish
4 Replies

7. Shell Programming and Scripting

shell script for delete old files

i want to delete all the files in my directory except the latest one. i need to do this from shell script. say i have a.txt - latest file b.txt, c.txt.. it should delete all the files except a.txt? (4 Replies)
Discussion started by: krishnarao
4 Replies

8. Shell Programming and Scripting

shell script to delete directories...

*Just realized that i posted this in the wrong forum. should have been in Shell, though it is on AIX... Hi. I'm trying to write a script that will delete all directories found, that are not named as a "number" (year)... here is what i mean, let's say i have within /data/exports the... (8 Replies)
Discussion started by: Stephan
8 Replies

9. Shell Programming and Scripting

shell script to delete directories...

Hi. I'm trying to write a script that will delete all directories found, that are not named as a "number" (year)... here is what i mean, let's say i have within /data/exports the following directories: /data/exports/2000 /data/exports/2001 /data/exports/2002 /data/exports/daily/2000... (5 Replies)
Discussion started by: Stephan
5 Replies

10. Shell Programming and Scripting

Need Help: Delete a file by Shell Script

Need some help here. We FTP out files to another server hourly. But before we can FTP to the other server. That server should send our server a "confirmation file" to tell us that they're ready to receive data. If they don't send the confirmation file, the files on our server should just stay... (5 Replies)
Discussion started by: r3edi
5 Replies
Login or Register to Ask a Question