Quick question : I want to delete all but 1 file and 1 directory from the directory I am currently in. How do I do this?
The case scenario :
I have a directory which has three directories a b c and three files 1.php 2.php 3.php. I want to remove directories a,b and files 1.php and 2.php ONLY! I am having a hard time trying to do this.
The solution should scale up, i.e. I don’t want to have to list all the files I do want to delete, only the ones that should stay.
What do I do?
in bash
Demo
See pattern matching in the bash manual.