nixCraft Linux Forum

nixCraft

Linux 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

Register FAQ Members List Calendar Mark Forums Read
  #1 (permalink)  
Old 05-08-2008, 12:44 PM
Junior Member
User
 
Join Date: May 2008
My distro: Debian
Posts: 2
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
Sponsored Links
  #2 (permalink)  
Old 05-08-2008, 05:41 PM
Junior Member
User
 
Join Date: May 2008
My distro: fedora
Posts: 20
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 05-09-2008, 07:51 AM
Junior Member
User
 
Join Date: May 2008
My distro: Debian
Posts: 2
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 05-09-2008, 12:46 PM
Junior Member
User
 
Join Date: May 2008
My distro: fedora
Posts: 20
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 05-09-2008, 07:24 PM
rockdalinux's Avatar
Contributors
User
 
Join Date: May 2005
Location: Bangalore
My distro: RHEL, HP-UX, Solaris, FreeBSD, Ubuntu
Posts: 576
Rep Power: 7
rockdalinux is a jewel in the rough rockdalinux is a jewel in the rough rockdalinux is a jewel in the rough rockdalinux is a jewel in the rough
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.
You may have my body & soul, but you will never touch my pride!

If you have knowledge, let others light their candles at it.

Certified to work on HP-UX / Sun Solaris / RedHat
Reply With Quote
Reply

Bookmarks

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 On

Similar Threads

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


All times are GMT +5.5. The time now is 11:21 AM.


Powered by vBulletin® Version 3.7.3 - Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0

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