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


Click here to return to the 'beware of filenames starting with a space' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
beware of filenames starting with a space
Authored by: hayne on Oct 14, '02 02:10:14PM
This trick relies on the sorting order of filenames. If you happen to have a filename which starts with a character that comes before the '-' character in the sort order, this trick will not work since that filename will come earlier in the command line than the -i and hence the -i will not be recognized as an to rm. Perhaps the most common case when this might trip you up is if a filename started with a space. It is quite easy to do this (even inadvertantly) in the Finder. You can also create such a file in Terminal by using quotes. For example:
    touch " foo"
creates a file called " foo" (with a space as the first character). You can see what trouble this would cause by looking at the result of:
    echo *
That shows that the file " foo" comes before the file "-i" in the list. You can avoid most such difficulties by creating your "-i" file with a bunch of extra spaces in front of its name:
    touch "             -i"


[ Reply to This | # ]