Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

428
Visualizações
Argument list too long error rm command

I have a Linux based server using which i do some file manioulation and serve multiple other servers of mine.

Basically this server (say server1) takes input as .mp3 file from other servers and converts to other file formats (.wav, .txt and .xml) and sends the asked response to other servers.

Over a period of time this folder of mine (Say /Somepath/MyInputFolder) has now GBs of data which i want to delete.

I tried the rm -r * command but it says:

Argument list too long

I also tried rm -r *.mp3 and rm -r *.txt to delete these files separately, but its gives the same error.

I also tried this SO question and read this link.

I tried the solution of above SO question and got the error as warning.

find . -name "*.txt" -maxdepth 1 -print0 | xargs -0 rm
find: warning: you have specified the -maxdepth option after a non-option argument -name, but options are not positional (-maxdepth affects tests specified before it as well as those specified after it).  Please specify options before other arguments.

How can i achieve this?

over 4 years ago · Santiago Trujillo
3 Respostas
Responde à pergunta

0

As already stated in the comment to the answer you linked, you need to put the -maxdepth directly after the path. Like so:

find . -maxdepth 1 -name "*.txt" -print0 | xargs -0 rm
over 4 years ago · Santiago Trujillo Relatório

0

ls | tail -10000 | xargs rm -rf

Executed more times.

over 4 years ago · Santiago Trujillo Relatório

0

This has been answered, but I wanted to add this for those will come across this question.

find has its own -delete option which will delete the files it finds. So you can simply do:

find -maxdepth 1 -name "*.txt" -delete

If you are interested in reading more about this issue, I would suggest this link.

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda