File matches with structured information
by Faki from LinuxQuestions.org on (#5S5M7)
The following grep command that returns the files that contain the string ptrn.
Code:grep -rl "${isufx[@]}" -e "$ptrn" -- "${fdir[@]}" >> $logflThis would be the result
Code:cat /home/flora/logs/27043-T13:09:44.893003954.log
%rec: edvart
Ptrn: Gnu
/home/flora/file1.sh
/home/flora/file2.sh
/home/flora/file3.sh
/home/flora/file4.sh
/home/flora/file5.sh
/home/flora/file6.shI would like to end up with the following
Code:cat /home/flora/logs/27043-T13:09:44.893003954.log
%rec: edvart
Ptrn: Gnu
File: file1.sh
+ /home/flora/file2.sh
+ /home/flora/file3.sh
+ /home/flora/file4.sh
+ /home/flora/file5.sh
+ /home/flora/file6.sh
Code:grep -rl "${isufx[@]}" -e "$ptrn" -- "${fdir[@]}" >> $logflThis would be the result
Code:cat /home/flora/logs/27043-T13:09:44.893003954.log
%rec: edvart
Ptrn: Gnu
/home/flora/file1.sh
/home/flora/file2.sh
/home/flora/file3.sh
/home/flora/file4.sh
/home/flora/file5.sh
/home/flora/file6.shI would like to end up with the following
Code:cat /home/flora/logs/27043-T13:09:44.893003954.log
%rec: edvart
Ptrn: Gnu
File: file1.sh
+ /home/flora/file2.sh
+ /home/flora/file3.sh
+ /home/flora/file4.sh
+ /home/flora/file5.sh
+ /home/flora/file6.sh