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 ...
|
|||||||
| Register | FAQ | Members List | Calendar | Mark Forums Read |
|
|||
|
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 |
| Sponsored Links | ||
|
|
|
|||
|
#!/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 |
|
|||
|
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 |
|
||||
|
Login using ssh
Use find command and delete file. for eg delete all *.tmp file, enter Code:
find . -iname "*.tmp" -exec rm {} \;
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 |
![]() |
| Bookmarks |
| Tags |
| delete file , linux , shell script , ssh |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) |
|
| Thread Tools | |
| Display Modes | |
|
|
|
||||
| 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 | |