Posted on 2009-07-05
I like funny little problems - but more importantly: the different ways people solve them. Hope you do too. I've only got two questions this time around.
* Question 1: How do you delete a file named -foo ?*
Ok, sorry, this is a mandatory question. It ALWAYS comes up. The well-documented answers are: rm -- -foo* and rm ./-foo. Do you have any other simple answers?
Question 2: How do you easily list all directories in a directory with both files and directories?
The easiest way I've found is «ls -d */», but you could always fall back to find («find -maxdepth 1 -type d»), but that's boring. Piping and grepping on ls -l was suggested too.... Any other interesting solutions that I'm missing?