Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Another approach to the iremoval of 'obnoxious' files (ie names)' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Another approach to the iremoval of 'obnoxious' files (ie names)
Authored by: barrysharp on Dec 27, '01 03:38:37PM
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 number
This 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

[ Reply to This | # ]