Home > Mobile >  Removing lines from text list that don't match expression
Removing lines from text list that don't match expression

Time:01-04

I've made a script that lists movies that I've processed from DVDs for Kodi into a text file. In the example below I'd like to remove any entry that doesn't contain the year (YYYY). What is the best way to do this?

300 (2006).mkv
42nd Street (1933).mkv
47 Ronin (2013).mkv
A1_t00.mkv
A1_t01.mkv
A1_t01.mkv

New to bash scripting and explored a couple sites with awk and sed.

CodePudding user response:

awk '/[0-9][0-9][0-9][0-9]/ {print}' list.txt >  filteredlist.txt

Filters text for a 4 digit number (year), excluding all the extras.

  • Related