Page tree
Skip to end of metadata
Go to start of metadata

Cut's man pages are not that clear so let's start with examples,

End goal is to extract out name of episodes.

Sample Data

ls
Episode 1-Pilot.avi
Episode 10-False Flag.avi
Episode 11-Dead Drop and 12-Loose Ends.avi
Episode 2-Identity.avi
Episode 3-Old Friends.avi
Episode 4-Fight Or Flight.avi
Episode 5-Family Business.avi
Episode 6-Unpaid Debts.avi
Episode 7-Broken Rules.avi
Episode 8-Wanted Man.avi
Episode 9-Hard Bargain.avi

Let's ask cut to separate each line into two fields using "-" has the delimiter,

ls | cut -d'-' -f2
Pilot.avi
False Flag.avi
Dead Drop and 12
Identity.avi
Old Friends.avi
Fight Or Flight.avi
Family Business.avi
Unpaid Debts.avi
Broken Rules.avi
Wanted Man.avi
Hard Bargain.avi

And to finally separate the end part run cut again,

ls | cut -d'-' -f2 | cut -d'.' -f1
Pilot
False Flag
Dead Drop and 12
Identity
Old Friends
Fight Or Flight
Family Business
Unpaid Debts
Broken Rules
Wanted Man
Hard Bargain
  • No labels