简体   繁体   中英

How can I pipe the output of 'find' into a command that will execute 'more' piped into 'grep' on package.json two directories up?

I am trying to find which package.json is causing a dependency warning. It's coming from a sub-module. I have a find command find . -name 'foo' find . -name 'foo' that outputs

/a/very/very/very/long/path/to/a/submodule/.../node_modules/foo
/another/very/very/very/long/path/to/a/submodule/.../node_modules/foo

I want to see what version of foo is included in the parent module's package.json. Something like this

more "$find_output"/../../package.json | grep foo

弄清楚了:

find . -name 'foo' -print0 | xargs -0 bash -c 'for path; do more "$path"/../../package.json | grep "foo"; echo $path; done ' bash

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM