on-internet
← Community

Picking out file names from grep results where file name contains numbers and hyphens

Stack Overflow ·

I have a script that runs a grep command and formats the results nicely for me, asking if I want to open any of the resulting files in an editor etc. The core of my script is a command like this: grep -HinER -B 0 -A 2 --include "*.txt" "eight" /tmp/searchTest/letters | sed -re "s/:([0-9]+:)/\n\1/" -e "s/-([0-9]+-)/\n\1/" -e "s/^[.]/\\n./" It runs the grep, outputting the file name on every line and then runs some processing to put the file names on a different line from the results. > grep -HinER -B 0 -A 2 --include "*.txt" "eight" /tmp/searchTest/letters | sed -re "s/:([0-9]+:)/\n\1/" -e "s/-

Comments

Sign in or sign up to comment and upvote.

No comments yet.