![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Linux RedHat, Ubuntu, SUSE, Fedora, Debian, Mandriva, Slackware, Gentoo linux, PCLinuxOS. All Linux questions here! |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| deleting specific lines from all files in a directory | vrms | UNIX for Dummies Questions & Answers | 3 | 04-25-2008 08:08 AM |
| deleting empty files in a directory | berlin_germany | Shell Programming and Scripting | 5 | 01-26-2007 12:47 PM |
| shell script: deleting files from a directory | onlyc | Shell Programming and Scripting | 1 | 07-09-2006 03:41 AM |
| Accidentally deleting directory/files | milhan | UNIX for Advanced & Expert Users | 4 | 08-27-2003 06:59 AM |
| Deleting A Directory! | firefinger | UNIX for Dummies Questions & Answers | 2 | 10-19-2001 09:17 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
#8
|
||||
|
||||
|
That's right, sometimes we miss the simple... |
| Forum Sponsor | ||
|
|
|
#9
|
|||
|
|||
|
yes sometimes we just miss the simplest things. however take note it still suffers from "argument too long" issues if there are too many directories ( maybe there's a workaround somewhere)
Code:
# ls -p | grep "/" | wc -l
31998
# rm -r */
bash: /bin/rm: Argument list too long
# ls -p|awk '/\/$/&&!/\./' | xargs -i rm -rf "{}"
# ls -p | grep "/" | wc -l
0
|
|
#10
|
||||
|
||||
|
Quote:
Anyway, I don't think ls and awk are needed in this case and I'd try to handle pathological dirnames (embedded spaces, newlines or other special characters) . |
|
#11
|
|||
|
|||
|
yes, that's why rm -f */ is the simplest solution to his problem. No doubt about that.
|
|
#12
|
||||
|
||||
|
Quote:
Just to make it clear, I don't think ls and awk are needed in the case you describe (argument list too long). Code:
for d in */;do rm -r "$d";done Code:
xargs -0n1000 rm -r < <(printf "%s\000" */) Code:
autoload -U zargs zargs *(/) -- rm -r Last edited by radoulov; 04-13-2008 at 10:36 AM. Reason: corrected |
|
#13
|
|||
|
|||
|
damn,
i was just experimenting rm -rf */ i just typed /* |
|
#14
|
||||
|
||||
|
find /path -type d -exec rm -rf {} \;
|
||||
| Google The UNIX and Linux Forums |
| Thread Tools | |
| Display Modes | |
|
|