Linux -bash: /bin/rm: Argument list too long

Hi,

When Anydisk or mount point is full in linux, you need to delete files. You can get ” -bash: /bin/rm: Argument list too long ” error during

 

 

You want to delete all audit files which are .aud extension like following.

[root@MehmetSalih audit]# rm -rf *aud
-bash: /bin/rm: Argument list too long





But you got ” -bash: /bin/rm: Argument list too long ” error, to solve this problem you can use following command.

 

[root@MehmetSalih audit]#  find . -name "*aud" -print | xargs rm -rf

 

 

You can change *aud extension to the *trc or *trm. You can delete all trc extension files like following if their argument list too long.

[root@MehmetSalih audit]#  find . -name "*trc" -print | xargs rm -rf

 

[root@MehmetSalih audit]#  find . -name "*trm" -print | xargs rm -rf

[root@MehmetSalih audit]#  find . -name "*.log" -print | xargs rm -rf




Or You can use Following solutions to solve this problem.

find . -name "*aud" -delete

find . -type f -name "FILE-TO-FIND" -exec rm -f {} \;

find . -name "*aud" -print | xargs rm -rf

Mehmet Salih Deveci

I am Founder of IT Tutorial and Certified Expert about Oracle & SQL Server database, Goldengate, Exadata Machine, Oracle Database Appliance administrator with 10+years experience. I have OCA, OCP, OCE RAC Expert Certificates I have worked 100+ Banking, Insurance, Finance, Telco and etc. clients as a Consultant, Insource or Outsource. I have done 200+ Operations in this clients such as Exadata Installation & PoC & Migration & Upgrade, Oracle & SQL Server Database Upgrade, Oracle RAC Installation, SQL Server AlwaysOn Installation, Database Migration, Disaster Recovery, Backup Restore, Performance Tuning, Periodic Healthchecks. I have done 2000+ Table replication with Goldengate or SQL Server Replication tool for DWH Databases in many clients. If you need Oracle DBA, SQL Server DBA, APPS DBA,  Exadata, Goldengate, EBS Consultancy and Training you can send my email adress mehmetsalih.deveci@outlook.com. -                                                                                                                                                                                                                                                 - Oracle DBA, SQL Server DBA, APPS DBA,  Exadata, Goldengate, EBS ve linux Danışmanlık ve Eğitim için  mehmetsalih.deveci@outlook.com a mail atabilirsiniz.

7 thoughts on “Linux -bash: /bin/rm: Argument list too long

  • June 23, 2019 at 9:00 pm
    Permalink

    You say you are trying to remove “files” but the -r option will also remove the ./not_aud/ directory and all its contents. That might not be what some users want.

    Also note that if you have a file:

    ./somedir/somefile.aud

    And you run:

    % rm -rf *aud

    the file will NOT be removed, but if you run:

    % find . -name “*aud” -print | xargs rm -rf

    the file WILL be removed!

    Reply
  • June 28, 2019 at 8:57 pm
    Permalink

    I used to have to run this command — or one like it — fairly frequently for one group that I worked with who would contact me when they noticed these files and the dreaded “Argument list too long” error was being returned. The questions that nobody in the group seemed to be able to answer were: 1.) Why are all these “.aud” files being created if nobody’s using them for anything and 2.) Is there a way to prevent them from being created in the first place, again, if they’re not being used. Nobody ever had an answer to those questions. I’d clean them out for the people who complained all the files and they’d never be thought again until the next time someone noticed that there were 60K-100K of them littering the filesystem (and slowing down the nightly backups when that directory was encountered).

    Reply
  • August 6, 2019 at 12:43 pm
    Permalink

    Or simply:

    find . -name “FILE-TO-FIND” -exec rm -rf {} \;

    OR

    find . -type f -name “FILE-TO-FIND” -exec rm -f {} \;

    Reply
  • August 29, 2019 at 5:15 pm
    Permalink

    even simpler:
    find . -name “*aud” -delete

    Reply
  • August 30, 2019 at 1:39 pm
    Permalink

    Other Method:

    for file in *; do rm -f $file;done

    or (if you want to delete also directories):

    for file in *; do rm -rf $file;done

    Reply