Remove content between two files

Asked

Viewed 74 times

1

I have two files. A file contains words like a dictionary and another file, contains logs. I would like the file containing the information (Dictionaries) to be removed from the Log file. Remove the full log line and not just the word.

Unsuccessful attempts:

grep -f dicionario.txt -v logs.txt

or

while read line; do egrep -v "$line" logs.txt; done < dicionario.txt >> filtrado.txt

The first command generated this error:

grep: Refer▒ncia anterior inv▒lida

The second I believe that he reads the list of dictionaries line by line and as he does not find the reference he saves in filtrado.txt. Thus the filtered.txt file is around 180 MB, while the original Log file is only 3 MB.

Contents of x.txt

Aaroon NB / Inv. 8120403678
ABRIGO SALAS  -  RIFA DE MAIO 2018
Academia e fatura cartão
Acesso por celular
Adequate! I wish to talk.
Adesivos
adventurous, I wish to speak:-)
AIR CROSS
Aluguel Anderson - porto feliz
ANALISTA DE FOLHA PGTO SR
Andamento do seu pedido!
angel
angelic How so?

Log.txt

May 10 03:29:23 xxxxxxx[28161]: ID: xxxxx; IP: xxxxx; MSGID: <[email protected]>; X-UOL-SMTP: xxxx; SENDER: <[email protected]>; SUBJECT: Коммерческое предложение главному; URL: xxx.com.br;

Grateful.

  • Enter the programming language used.

  • I used Regular expression, shell.

  • What are the contents of the files? At least one part.

  • I edited my comment with the content.

1 answer

0

Use the SED, find a pattern in the lines you want to delete sed '/<padrão que contem na linha que deseja excluir do arquivo/d' dicionario.txt >> filtrado.txt

  • Good Afternoon. I solved my problem in a very simple way {grep -ff file_total.txt -v file_data_a_ser_removed.txt} Hugs.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.