Created
August 10, 2016 22:35
-
-
Save tsleyson/f1961129d850272175f898db48e5db09 to your computer and use it in GitHub Desktop.
How to get all the lines of a file starting from the first one that matches a regex, up to the end
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tail -n $(grep -n -m 1 "regex to match" "source file" | cut -d : -f1) "source file" > "dest file" | |
# The above throws away the first line that matches the regex. This will keep that line: | |
tail -n $(( $(grep -n -m 1 "regex to match" "source file" | cut -d : -f1) - 1)) "source file" > "dest file" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Say we have this file:
Run this command:
to get this output:
Run the second version to get this output: