Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ideas to delete special char file/dir names in script?

Status
Not open for further replies.

BobMCT

IS-IT--Management
Sep 11, 2000
756
US
While trying to migrate a friends web site tree to another machine I've come across a situation where I've found some illegal (at least for scripting) file/directory names.

In particular I've encountered a directory with the following name:

<img alt="HomepricevsPay.jpg" src="http:

Now - manually I can force this delete with wild cards but I have a script for repeatability and the area where I'm trying to delete this is failing as follows:

cannot access `public_html/columns/<img':
No such file or directory
cannot access `alt="HomepricevsPay.jpg"':
No such file or directory
cannot access `src="http:/No such file or directory

I'm sure you get the picture.

The script snippet I'm using is here:

# Remove any illegal file/directory names from tree
echo "Scanning for illegal directory/file names..."
find . -name "*<*" -print > tmp.1
sed -i "s/\ /\?/g" tmp.1
for x in $(cat tmp.1)
do
echo "Removing file/directory $x"
rm -rf $x*
done
rm -f tmp.1

So, if any of you guru's have a good idea/recommendation I would certainly appreciate a response. As always on this site - thank you all very much! [nosmiley]
 
Something like this maybe...
Code:
find . -type d -print | sed -n '/</p' | xargs rm -rf


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top