I want to remove a folder contents and it's sub-folder contents without removing hidden files in folder and sub-folders. How can i do it by using shell script??
I have tried rm -rf foldername but it is removing entire contents.
|
|
|
Instead of using
|
|||
|
|
|
That's a tricky one. An outline solution might be:
The first command removes files with a name not starting with You might run into issues with symlinks, Unix sockets, FIFOs, and other non-files; tweak the first command to suit your requirements. If you use |
|||
|
|
|
by passing an argument
|
|||||
|
|
You could use this command:
The find command finds all files under foldername/ whose names don't start with a '.' (hidden file), and passes them to xargs, which runs rm -f on them. |
|||
|
|