Remove all lines that don't end with specific string
-
21-12-2019 - |
سؤال
working on a large text file and I'd like to remove all lines that don't contain the text "event":"click"}]
I've tried to do some regex within Sublime 3 and can't get it to stick.
المحلول
I have not used sublime but you could select all line not containing the text "event":"click"}]
with the regex:
^(.(?!"event":"click"\}\]))*$
I think you could replace them by nothing(empty string) or backspace
نصائح أخرى
Use this one to get result to stdout
sed -n '/"event":"click"\}\]$/p' your_large_file
Use this one to keep only lines that end with "event":"click"}]
, your_large_file.old backup will be generated
sed -i.old -n '/"event":"click"\}\]$/p' your_large_file
لا تنتمي إلى StackOverflow