nixCraft Linux Forum

nixCraft

Linux / UNIX Tech Support Forum

Script to delete a set of files in Remote machine

This is a discussion on Script to delete a set of files in Remote machine within the Shell scripting forums, part of the Development/Scripting category; Hi Guys ,, i need ur help... Its urgent I want a shell script to delete a set of files ...


Go Back   nixCraft Linux Forum > Development/Scripting > Shell scripting

Linux answers from nixCraft.


Shell scripting You can discuss the shell scripting, request shell scripts and scripting techniques

Reply

 

LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 08-05-2008, 12:44 PM
Junior Member
User
 
Join Date: May 2008
OS: Debian
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
ashok333 is on a distinguished road
Default Script to delete a set of files in Remote machine

Hi Guys ,,

i need ur help... Its urgent
I want a shell script to delete a set of files in remote machine.
Files names can be provided thru a .txt file.
.txt content will be

one.html
two.html
.
.
.
etc


thanks in advance
ashok
Reply With Quote
  #2 (permalink)  
Old 08-05-2008, 05:41 PM
permalac's Avatar
Member
User
 
Join Date: May 2008
Location: barcelona
OS: debian,opensuse,opensolaris,centos,fedora,backtrack
Posts: 36
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
permalac is on a distinguished road
Default

#!/bin/bash
# usage script.sh <file with the list of files you want to erase>
# notice that rm -rf is used !!! i'm not responsible of this. (just a common tipo)



filewithlist=$1

for file in `cat $filewithlist`
do

rm -rf $file
echo "$file erased"

done
Reply With Quote
  #3 (permalink)  
Old 09-05-2008, 07:51 AM
Junior Member
User
 
Join Date: May 2008
OS: Debian
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
ashok333 is on a distinguished road
Default

thanks for ur reply, actually my .txt file will have just filenames.
So i need to search for that file in the following sub-directories.

requirement is like search and delete the file
can i do this process in remote server, where i will run script in local and delete files in remote server??
for ur info am using Solaris .

thanks
ashok
Reply With Quote
  #4 (permalink)  
Old 09-05-2008, 12:46 PM
permalac's Avatar
Member
User
 
Join Date: May 2008
Location: barcelona
OS: debian,opensuse,opensolaris,centos,fedora,backtrack
Posts: 36
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
permalac is on a distinguished road
Default

I've never used solaris.

anyway, may be you can have the full path of your files , and search for them with locate.

good luck.
Reply With Quote
  #5 (permalink)  
Old 09-05-2008, 07:24 PM
rockdalinux's Avatar
Is that all you got?
User
 
Join Date: May 2005
Location: Planet Vegeta
OS: Redhat
Posts: 708
Thanks: 15
Thanked 19 Times in 18 Posts
Rep Power: 10
rockdalinux is a glorious beacon of light rockdalinux is a glorious beacon of light rockdalinux is a glorious beacon of light rockdalinux is a glorious beacon of light rockdalinux is a glorious beacon of light rockdalinux is a glorious beacon of light
Default

Login using ssh

Use find command and delete file. for eg delete all *.tmp file, enter
Code:
find . -iname "*.tmp" -exec rm {} \;
You can also run command using ssh
Code:
ssh user@solaris.box.com find . -iname "*.tmp" -exec rm {} \;
__________________
Rocky Jr.
What's wrong? I hope I am not making you uncomfortable...

Never send a boy to do a mans job.
Reply With Quote
Reply

Tags
delete file , linux , shell script , ssh


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads

Thread Thread Starter Forum Replies Last Post
How do I delete copyright protected files? raj Getting started tutorials 5 25-03-2008 12:48 AM
i need a script to delete one folder with files on my ftp silver_ch Shell scripting 1 27-03-2007 10:15 AM
Shell script for automatic conversion of files in tar files kasimani Shell scripting 2 08-02-2007 03:45 PM
Linux find and delete files cbzee Linux software 4 20-12-2006 12:01 PM
can ext3 securely delete files Linux software 1 11-01-2006 12:08 PM


All times are GMT +5.5. The time now is 05:54 AM.


Powered by vBulletin® Version 3.8.5 - Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2
©2005-2010 nixCraft. All rights reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38