The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How to remove user from a group using command line civic2005 SUN Solaris 2 2 Weeks Ago 11:05 AM
question on find and remove command arunkumar_mca UNIX for Dummies Questions & Answers 1 12-10-2007 09:54 PM
sh, ksh: command to remove front spaces from a string? pseudocoder Shell Programming and Scripting 3 09-22-2007 04:57 AM
command to remove last record on file mheinen UNIX for Dummies Questions & Answers 4 01-09-2007 12:39 PM
search and remove command jasonr UNIX for Dummies Questions & Answers 3 09-05-2003 12:15 PM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 12-19-2007
jambesh's Avatar
Registered User
 

Join Date: Aug 2006
Location: Pune,India
Posts: 118
Stumble this Post!
rm command not able to remove file

I have directory IXNPG7 under which i have seen file ads[1].c , ads[1].gif ,
ads[1].js and lots more with extension .html

I tried to remove the Entire Directory with rm -Rf IXNPG7
but it is saying -- Directory Not empty can't remove

Secondly i tried removing all the files first

using rm *.* inside that directory all files get removed except ads[1].c

i tried to remove using rm -fr ads[1].c --after issuing the command the
rm is silent with out any error,but not able to delete this file ?

1 -- Can you please tell me why the directory is not removed recursively
2-- Why this FILE is not removing ?
3- Some time this directory contains a file whose name more then 1 line of characters and denied removing saying too long file name ?

Please tell me what could be the reason ?

Thanks
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 12-19-2007
Registered User
 

Join Date: Jan 2007
Posts: 2,965
Stumble this Post!
1. What platform is this?

2. Have you tried

Code:
chmod -R +w directory
rm -rf directory
Reply With Quote
  #3 (permalink)  
Old 12-19-2007
Registered User
 

Join Date: Oct 2007
Location: USA
Posts: 539
Stumble this Post!
Let the system help you in removing that file. Answer "y" to all the files the system prompts you for deletion.

Code:
rm -i * .*
Reply With Quote
  #4 (permalink)  
Old 12-19-2007
Read Only
 

Join Date: Nov 2007
Posts: 165
Stumble this Post!
You could try putting the filename in single quotes, like:
Code:
rm 'ads[1].c'
I think the shell is trying to interpret the "[1]" as a pattern to match any single character within the square brackets (ie. you are trying to remove the file ads1.c).
Reply With Quote
  #5 (permalink)  
Old 12-20-2007
jambesh's Avatar
Registered User
 

Join Date: Aug 2006
Location: Pune,India
Posts: 118
Stumble this Post!
trid all the options

I am using Cygwin on WIN xp

I have tried all the above recomended option to delete the file and Folder
but those folder and file are not able to remove from cygwin using the rm command ,
But when i am trying to open the internet explorer property and remove all the offline contents then only it is removing.

Please suggest

I have seen that these are the virus file generating jsut by connecting to Internet.

I want to remove these file in every 10 sec by writing a UNIX script in cygwin.

these file are getting created in /cygdrive/c/Document and setting/user/local setting/Temporary Internet files

presently i have wriiten the script to check the desktop.ini file in this directory and the SUBfolder in this directory.

It is removing the desktop.ini but not able to remove the subfoder -- here is the script i am using ---

---------------------------SCRIPT----------------
#!/bin/sh
VIRUS_DIR="/cygdrive/c/Documents and Settings/User/Local Settings/Temporary Internet Files/Content.IE5/"
vf_1="ads[1].c"
vf_2="6[1].gif"
vf_3="desktop.ini"

while true
do
##########################################

cd "$VIRUS_DIR"
echo "Current Directory now " `pwd`

if [ -f $vf_1 ]
then
rm -fr ${vf_1}
if $? -eq 0
then
echo "Virus found $vf_1 and removed "
fi
else
echo "No virus file $vf_1 now "
fi
##########################################
if [ -f $vf_2 ]
then
echo "Virus found $vf_2 "
rm -fr $vf_2
else
echo "No virus file $vf_2 now "
fi
########################################
if [ -f $vf_3 ]
then
echo "Virus found $vf_3"
/usr/bin/rm -f desktop\.ini
if [ $? -eq 0 ]
then
echo "Virus ${vf_3} removed successfully"
fi
else
echo "No such virus file found "
fi
############################################
# echo "Now removing unnecessary directory"
for i in *
do
if [ -d $i ]
then
cd $i
rm -fr *
if [ $? -eq 0 ]
then
echo "Removed all file from $i directory "
else
cd ..
chmod 000 $i
continue
fi
cd ..
rm -fr $i && echo "Removed directory $i "
fi
done
echo "Looking back and checking desktop-ini-virus"
cd ../
if [ -f $vf_3 ]
then
echo "Virus found $vf_3 in " `pwd`
/usr/bin/rm -f desktop\.ini
if [ $? -eq 0 ]
then
echo "Virus ${vf_3} removed successfully"
fi
else
echo "No such virus file found "
fi

if [ -f ads.js ]
then
rm -fr ads.js
if [ $? -eq 0 ]
then
echo "Virus : ads.js found and removed "
fi
fi
echo "Sleeping for 10 seconds ......"
sleep 10
done
Reply With Quote
  #6 (permalink)  
Old 12-20-2007
Registered User
 

Join Date: Jan 2007
Posts: 2,965
Stumble this Post!
Quote:
Originally Posted by jambesh View Post
I am using Cygwin on WIN xp
oh

Quote:
Originally Posted by jambesh View Post
these file are getting created in /cygdrive/c/Document and setting/user/local setting/Temporary Internet files


Have you heard of "cmd.exe" this has a command "del". It's quite useful on Windows machines.
Reply With Quote
  #7 (permalink)  
Old 12-21-2007
jambesh's Avatar
Registered User
 

Join Date: Aug 2006
Location: Pune,India
Posts: 118
Stumble this Post!
Hi Porter ,


I know your are talking about the window del - right ? Instead, i would prefer to remove it from IE property the same Manual work.

i don't want to issue this command every single time from command prompt.
so i was think of a script .
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 05:19 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0