Skip to content

Instantly share code, notes, and snippets.

@GGontijo
Created February 3, 2024 13:12
Show Gist options
  • Save GGontijo/ccd1bff3fdb09c3c217adfdaa7d0e176 to your computer and use it in GitHub Desktop.
Save GGontijo/ccd1bff3fdb09c3c217adfdaa7d0e176 to your computer and use it in GitHub Desktop.
linux find text pattern in texts and write something in front of them
palavra="teste"; texto_adicional="deu certo"; for arquivo in teste*; do grep -q "$palavra" "$arquivo" && sed -i "/$palavra/ s/$/ $texto_adicional/" "$arquivo" && echo "Texto adicionado em $arquivo"; done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment