Note that not all versions of tail support the plus-notation. If you want to start from the last match instead of the first match it would be: tail -n +$(( 1 + $(grep -n -f file2 file1 | tail -n1 | cut -d: -f1) )) file1 The embedded grep and cut find the first line containing a pattern from file2, this line number plus one is passed on to tail, the plus one is there to skip the line with the pattern. pattern in file2, grepping from file1: tail -n +$(( 1 + $(grep -m1 -n -f file2 file1 | cut -d: -f1) )) file1 Here's an answer that comes closer to your needs, i.e. The -c option returns 3 so I thought that spaces and newlines may be getting excluded so I tried. grep + but if I test it with a text file: +++++ +++++ + ++ ++ which returns 3 empty lines.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |