i believe i need to use grep because i am searching multiple files and i need for the file name to appear as a header on each line. i am using terminal on macOS.
so say i have one file, file1, in directory 'dir' with the following contents:
>species one; trnF(ggc)
GGCCC
AACGC
>species one; rrnS
TAGCA
GGCAC
and an additional file, file2, in directory 'dir' with the following contents
>species two; trnF(gga)
GGACG
CGACG
GCAC
>species two; rrnS
GCATG
GGCAG
i'd like to get the following output:
dir/file1:>species one; trnF(ggc)
dir/file1-GGCCC
dir/file1-AACGC
--
dir/file2:>species two; trnF(gga)
dir/file2-GGACG
dir/file2-CGACG
dir/file2-GCAC
i can get a certain specified number of lines after the line with the pattern using -A:
$ grep -A 2 'trnF' dir/file*
but the files have a different number of lines after the grep command so i get the following:
dir/file1:>species one; trnF(ggc)
dir/file1-GGCCC
dir/file1-AACGC
--
dir/file2:>species two; trnF(gga)
dir/file2-GGACG
dir/file2-CGACG
how can i get all of the contents until the next '>' symbol?