Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

zsh: how to delete contents in folder without deleting the folder?

Tags:

linux

unix

zsh

I am using zsh and I want to delete contents of a folder without deleting the folder itself. What is the best way to go about this?

like image 530
Abulurd Avatar asked Feb 14 '23 15:02

Abulurd


2 Answers

rm -r myfolder/* will delete all files in that folder that do not begin with a dot.

Really the simplest solution is rm -rf myfolder && mkdir myfolder.

like image 108
Scott Lawrence Avatar answered Feb 16 '23 03:02

Scott Lawrence


You can just use rm -r path/to/dir/*.

like image 24
CalvinLee Avatar answered Feb 16 '23 04:02

CalvinLee