|
|
Another approach to the iremoval of 'obnoxious' files (ie names)
Sometimes files get created with very obnoxious names -- ones that are very difficult protecting from being interpreted as Shell meta characters and/or Shell substitutions. For example (a very simple case), take a file name such as '-lo' and try /bin/rm-ing it. Even protecting it with single quotes or backslash yields annoying difficulties. As original posting states/shows -- it can be removed if you're knowledgeable.
Note: I've used "backslash" as I didn't find an obvious way to insert the backslash character without it getting removed ;-)
Here's how I deal with (ie deleting) obnoxious file names
> echo xxx >'-lo'' # Create an obnoxious file with name '-lo' > ls -i # List the files to obtain file '-lo' inode numberThis shows the inode number for file '-lo' to be 374807. Now use the find command to remove the obnoxious file
> find . -inum 374807 -print -exec /bin/rm -- {} "backslash";
./-lo
This process can be made even easier by making a function for the find command. Call the function 'remove' as shown below.
function remove
{
inode=$1
find . -inum $inode -print -exec /bin/rm -- {} "backslash";
return 0
}
So this can be used as follows
remove 374807
Regards... Barry Sharp
|
SearchFrom our Sponsor...Latest Mountain Lion HintsWhat's New:HintsNo new hintsComments last 2 daysLinks last 2 weeksNo recent new linksWhat's New in the Forums?
Hints by TopicNews from Macworld
From Our Sponsors |
|
Copyright © 2014 IDG Consumer & SMB (Privacy Policy) Contact Us All trademarks and copyrights on this page are owned by their respective owners. |
Visit other IDG sites: |
|
|
|
Created this page in 0.05 seconds |
|