Hello i'm trying to find all occurrences of a word in a subfolder. While that seems to be easy i want that for each occurrence we will display the path and the name of the file followed by ' -> Line: ', followed by the number of the line containing this occurrence.
For example : example/example/file.png -> Line: 25
I tried to do : grep -rnl 'word' subfolder/ | sed 's/$/ -> Line : /'
But i can't find a way to print the line at the end Heres an example of what i get using this command : ( example/example/file.png -> Line:
)
Thanks in advance for your help
grep -rn 'word' subfolder | awk -F":" '{print $1 " -> " "Line: " $2}'
or using findfind -type f -exec grep -n 'word' {} + | awk -F":" '{print $1 " -> " "Line: " $2}'
grep -rn 'word' subfolder | awk -F":" '{print $1 " -> " "Line: " $2}'
worked for me