2
Using a discovery command utility I can grep the location of some directories, and I need to open containing files. I cannot use find with exec such as this example find . -name "*.txt" -exec vim {} +
.
If I don't modify the grep output, xargs works as this
searchUtilityCommand | grep keyword | xargs vim
But I actually need
searchUtilityCommand | grep keyword | xargs -I % vim %/extra/path
However, when doing that it opens the first hit, and after I close it opens the second; close it and open the third... I tried using
searchUtilityCommand | grep keyword | xargs -P 0 -I % vim %/extra/path
But it just fails. I also tried
vim `searchUtilityCommand | grep keyword | xargs -P 0 -I % vim %/extra/path`
No luck.
I thought awk
or sed
could be used, but I am not fluent with them and I dont know if its worth it. It could be something like
searchUtilityCommand | grep keyword | <awk modify grepped path> | xargs vim
Any help.
Thanks!
you where missing a comma at the end of sed regex. Works like a charm! thanks
searchUtilityCommand | grep keyword | sed -e 's,$,/extra/path,' | xargs vim
– manolius – 2019-10-06T08:10:53.120