From: rvaede on 10 Aug 2010 15:09 I have a folder with a bunch of sub folders. I am trying to run a script to remove all the files in the folders and sub folders. I don not want to remove the directories.
From: Chris F.A. Johnson on 10 Aug 2010 15:10 On 2010-08-10, rvaede wrote: > > I have a folder with a bunch of sub folders. > I am trying to run a script to remove all the files in the folders and > sub folders. > I don not want to remove the directories. In the directory containing the subdirectories: find . -type f -exec rm {} + -- Chris F.A. Johnson, author <http://shell.cfajohnson.com/> =================================================================== Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress) Pro Bash Programming: Scripting the GNU/Linux Shell (2009, Apress)
From: rvaede on 10 Aug 2010 15:13 On Aug 10, 3:10 pm, "Chris F.A. Johnson" <cfajohn...(a)gmail.com> wrote: > On 2010-08-10, rvaede wrote: > > > I have a folder with a bunch of sub folders. > > I am trying to run a script to remove all the files in the folders and > > sub folders. > > I don not want to remove the directories. > > In the directory containing the subdirectories: > > find . -type f -exec rm {} + > > -- > Chris F.A. Johnson, author <http://shell.cfajohnson.com/> > =================================================================== > Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress) > Pro Bash Programming: Scripting the GNU/Linux Shell (2009, Apress) Well done Chris. Thank you
From: Geoff Clare on 11 Aug 2010 08:45 Chris F.A. Johnson wrote: > On 2010-08-10, rvaede wrote: >> >> I have a folder with a bunch of sub folders. >> I am trying to run a script to remove all the files in the folders and >> sub folders. >> I don not want to remove the directories. > > In the directory containing the subdirectories: > > find . -type f -exec rm {} + The OP wanted to remove everything except the directories, so this would be a better fit for the request: find . ! -type d -exec rm {} + (in case there are any symlinks, FIFOs, etc. there). -- Geoff Clare <netnews(a)gclare.org.uk>
|
Pages: 1 Prev: Generating data depending upon the given size Next: $RANDOM |