You can use the
find command.
This works, but I'll be honest with you, I probably can't explain why. As such, you should try it out on an experimental directory (modeled after what you need it for):
Code:
find . -maxdepth 1 \( -path ./app -prune \) -o \( -regex "\./.*" -print \)
If that gives you a list of the top-level files and directories you want to delete, then you can delete them with this:
Code:
find . -maxdepth 1 \( -path ./app -prune \) -o \( -regex "\./.*" -print \) -exec rm -R {} \;
The reason I can't explain why is, my reading of the find command's man page, the -path, -prune, and -o options in this combination are not what I would expect to get this behavior. Then again, I could just be a moron and it's plain as day to everyone else.
Also, to be absolutely clear, the command needs to be run from the directory that contains the files to delete. If you want or need a command that isn't restricted like that, you could try:
Code:
find /path/to/dir -maxdepth 1 \( -path /path/to/dir/app -prune \) -o \( -regex "/path/to/dir/.*" -print \) -exec rm -R {} \;