I have the following command:
find /home/cas/plex-media/series/ -type f -name '*.srt' | grep -v .en.srt
Which will find all .srt
files, that are not .en.srt
in the directory and subdirectories of series
.
This will give me a list that could look like this:
/home/cas/plex-media/series/Scorpion/Season 4/Scorpion - S04E06 - Queen Scary.srt
/home/cas/plex-media/series/Scorpion/Season 4/Scorpion - S04E03 - Grow a Deer, A Female Deer.srt
/home/cas/plex-media/series/Devs/Season 1/Devs - S01E03 - Episode 3.srt
/home/cas/plex-media/series/Modern Family/Season 8/Modern Family - S08E21 - Alone Time.srt
This is a simplified version. There could be 5 or 300 outputs, where there could be 8 or 50 times Scorpion for example. The output varies very much.
I trying to find a command (that I could pipe behind the original command), that will be give me the result:
Scorpion, Devs, Modern Family
And not:
Scorpion, Scorpion, Scorpion, Scorpion, Devs, Devs, Modern Family, Modern Family, Modern Family,
Modern Family, Modern Family, Modern Family, etc..
You get the idea. For every show, one output. Not for every file.
It can be in another layout. It doesn't really matter (altough I'd prefer the layout above).
I've been trying around with grep but I just can't do it. So i'm basically asking: Do you have an idea how I could get the output above?
Thanks.
Assuming that the delimiter between the series title and the remainder of the filename is a consistent space-hyphen-space, you could do something like this with awk:
The
!seen[$1]
construct de-duplicates the results. The finalpaste
command turns the output from a newline-delimited list to a comma-delimited list.