PDA

View Full Version : [SOLVED] Bash, delete



prismctg
June 19th, 2012, 09:06 AM
How to remove all content from "example" folder , but i dont want to remove the "example" folder

click4851
June 19th, 2012, 09:43 AM
couldn't you use some wild cards to indicate all files and then provide the location of the folder? (just have to be careful with wildcards)

Something like this...

http://forums.techarena.in/windows-software/1373668.htm

nothingspecial
June 19th, 2012, 09:46 AM
rm -r example_folder/*

Patterns (http://mywiki.wooledge.org/BashGuide/Patterns)

prismctg
June 19th, 2012, 11:18 AM
Thanx all of you guys :)

v8YKxgHe
June 19th, 2012, 12:28 PM
rm -r example_folder/*

Patterns (http://mywiki.wooledge.org/BashGuide/Patterns)

Be careful when using this, as it doesn't do exactly what you may want it to do. For example, in Bash the wildcard glob "*" does not match dot-files by default, and you need to enable the "dotglob" option.

The following will suffice:


shopt -s dotglob
rm -r example_folder/*

prismctg
June 19th, 2012, 12:59 PM
Be careful when using this, as it doesn't do exactly what you may want it to do. For example, in Bash the wildcard glob "*" does not match dot-files by default, and you need to enable the "dotglob" option.

The following will suffice:


shopt -s dotglob
rm -r example_folder/* thank you AlexC