Wednesday, September 27, 2023

/bin/rm: argument list too long

 /bin/rm: argument list too long

what is the solution to this error on UNIX or Linux???

solution:

When UNIX admin tries to delete too many files using rm command then he came across this error to address this error he can follow below solution

1.

find /tmp/logs -mtime +90  -exec -rm -f {} \;

above command will pass list of files older than 90 days to rm and it will remove those files

2.

find /tmp/logs -mtime +90  -print |xargs rm -f

it will also remove files older than 90 days

How to pass argumnet to xargs using n option to make sure it will delete n number of file

find /tmp/logs -mtime +90  -print |xargs -n 20 rm -f

it will delete/remove file in set of 20 .


Thanks


No comments:

Post a Comment