Home > OS >  grep a word from a list of file as a result of grep before
grep a word from a list of file as a result of grep before

Time:01-11

I have a command to grep a file with fullpath that contain a "TypeId: 0", here is the command

grep -rnw /home/username/app/data/store/0/part/.mv -e "TypeId: 0" | awk -F ":" '{print $1}'

and here is the result: /home/username/app/data/store/0/part/.mv/521/1673332792072/segmentconfig.yaml /home/username/app/data/store/0/part/.mv/521/1673333077920/segmentconfig.yaml /home/username/app/data/store/0/part/.mv/521/1673333077920/segmentconfig.yaml.old /home/username/app/data/store/0/part/.mv/515/1672993850766/segmentconfig.yaml /home/username/app/data/store/0/part/.mv/515/1672993850766/segmentconfig.yaml.old /home/username/app/data/store/0/part/.mv/703/1672987004847/segmentconfig.yaml /home/username/app/data/store/0/part/.mv/703/1672987004847/segmentconfig.yaml.old

Now I confuse how to grep "numofvertice" from each file from that list. Anyone have an idea to solve this?

CodePudding user response:

You could try this:

grep -rnw /home/username/app/data/store/0/part/.mv -e "TypeId: 0" | awk -F ":" '{print $1}'|xargs -I{} grep "numofvertice" {}

CodePudding user response:

Like this (GNU grep):

<STDIN> | grep -oP '\b\S \.yaml' | xargs cat

Or with ack:

cd /home/username/app/data/store/0/part/.mv
ack -wl  -e "TypeId: 0" | xargs cat

From ack --help:

-l, --files-with-matches
Only print filenames containing matches

  • Related