P
P
Printip2021-04-29 13:10:49
linux
Printip, 2021-04-29 13:10:49

How to parse a list with grep?

Hello! You need to write a simple script. There is a data.txt file and a find.txt file The contents of data.txt

000 001
000
002
003 004 003
001
000 005 : 000 001 000 002 000 005 003 004 003 001 000 001 003 001



Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vladimir Kuts, 2021-04-29
@Printip

while read line; do
   cat data.txt | grep $line | tr -s '\r\n' ' '
   echo
done<find.txt

will output
000 001 000 002 000 005
003 004 003 001
000 001 003 001

S
Saboteur, 2021-04-29
@saboteur_kiev

while read;do grep $REPLY data.txt|tr -s '\n' ' '&&echo;done<find.txt

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question