I'm dealing with a txt file that lists a bunch of other txt files, a lot of which I have wrongfully duplicated.
I'm on macOS so the lines listing the duplicated files all end with the pattern (NUMBER).txt
. I want to delete all the lines that don't contain this pattern.
I came up with this command to test the regex but it does not work as it also prints the lines that end with (WORD).txt
:
sed '/\(\d\)\.txt$|\(\d\d\)\.txt$|\(\d\d\d\)\.txt$/p' file.txt
I know I'm missing something but I can't figure out what... Thanks for your help!
\d
not supported, etc – Sundeep Jul 04 '20 at 09:55\d
is not (traditional)sed
regex syntax; instead it's just ad
; did you try to read the sed manual page? – U. Windl Oct 08 '21 at 07:55