I am trying to find all *.md
at ${PWD}
, then grep for lines beginning with title:
and print it along with the absolute filepath -H
and the line number of the pattern match -n
, then I try to output the result in a table with separator -s
as :
find ${PWD} -type f -name "*.md" -exec bash -c 'i="$1"; grep -HnE "^title:" $1; | column -t -s :;' _ {} \;
This is working till grep but I am unable to create a table.
Also, from the correction suggested by @steeldriver, the exec seems to be happening on each find
result one by one, thereby table is not being created?
Sample Output
/Admin/Specification/Specification.md 2 title Specification
/Admin/GraphicCard/index.md 2 title "GraphicCard"
{}
? And what actually happens? Sample output would go a long way..._
is for$0
;
between the grep command and the pipe ...find ${PWD} -type f -name "*.md" -exec bash -c 'i="$1"; grep -HnE "^title:" $1 | column -t -s : ' _ {}\; > FILE
The columns are not preserved anymore. Could you suggest why?find
supports it, you can use{} +
in place of{} \;