Linux / UNIX Tech Support Forum
This is a discussion on -bash: /bin/rm: Argument list too long within the Shell scripting forums, part of the Development/Scripting category; Okay I have a folder on my Red Hat server that I want to clean up 2 times a week ...
|
|||||||
| Shell scripting You can discuss the shell scripting, request shell scripts and scripting techniques |
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
Okay I have a folder on my Red Hat server that I want to clean up 2 times a week I know how to add it to the crontab, but I am having an issue removing all these files because when I try to do a rm -rf * I get:
[root@server1 PDF for Output]# rm -rf * -bash: /bin/rm: Argument list too long So I was thinking maybe I need to make a script to clean it out, but i don't know how to get around the Argument list too long problem. Any help with this issue would be greatly appreciated. |
| Sponsored Links | ||
|
|
|
||||
|
Use find command along with xargs to get rid of the files
Code:
find /path/to/dir/delete -print0 -iname '*.txt' | xargs -0 /bin/rm -f
__________________
Vivek Gite Linux Evangelist |
|
||||
|
No rm command should not delete any folder. To select only files add -type f to find command:
Code:
find /path/to/dir/delete -type f -print0 -iname '*.txt' | xargs -0 /bin/rm -f
__________________
Vivek Gite Linux Evangelist |
![]() |
| Tags |
| find , finding file , rm command , xargs |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) |
|
| Thread Tools | |
| Display Modes | |
|
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Bash script | Murray | Shell scripting | 0 | 23-02-2009 08:38 AM |
| arg list too long - tar command | ali560045 | Shell scripting | 1 | 19-12-2008 03:56 PM |
| Argument list too long | raj | Shell scripting | 1 | 04-11-2008 10:04 AM |
| Bash not working! | Mwalimugini | Getting started tutorials | 4 | 24-03-2008 09:52 PM |
| How long the sys was running? | jithendra | Linux software | 2 | 16-10-2006 05:31 PM |