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

136
Visualizações
Commands terminated with the same char

How can I fix the follow line:

for line in $(cat /root/files_to_search); do find /opt/ -iname $line -exec rm {} >> files_founded.txt ; done

The problem is that the commands of for and -exec end with a semicolon, the for command has this statement

for i in something; do command ; done (do terminate with ;)

and find statment with -exec

find /path/ -name somestring -exec command \; (-exec also finish with ;)
over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

You don't even need to use -exec echo {} since that is default action in find. You can use this for loop:

while IFS= read -r line; do
    find /opt/ -iname "$line"
done < /root/files_to_search >> files_founded.txt

There is no need to use for line in $(cat ...) either as you can read from the input using < file

See BASH FAQ on reading a file line by line

If you must use -exec in find then use:

while IFS= read -r line; do
    find /opt/ -iname "$line" -exec rm {} \;
done < /root/files_to_search >> files_founded.txt
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