How to extract fixed number of characters in every line of a text file using a script in macOS

Viewed 28

I have a text file which looks like this (yes there's 9 chars of space before [<asset]):

    <asset name="B168C015_210810_RO7O.[0691425-0692837].arx" start="230475/8s" format="r1" hasVideo="1" id="r2" src="file:///Volumes/ELT_Team_B_Clone_01/20210809_Day_041/Camera_Media/Cam_B/B168RO7O_hde/B168RO7O/B168C015_210810_RO7O/B168C015_210810_RO7O.[0691425-0692837].arx" duration="471/8s"/>
    <asset name="B168C004_210810_RO7O.[0587920-0589477].arx" start="73490/3s" format="r1" hasVideo="1" id="r3" src="file:///Volumes/ELT_Team_B_Clone_01/20210809_Day_041/Camera_Media/Cam_B/B168RO7O_hde/B168RO7O/B168C004_210810_RO7O/B168C004_210810_RO7O.[0587920-0589477].arx" duration="779/12s"/>
    <asset name="B168C016_210810_RO7O.[0696526-0697894].arx" start="348263/12s" format="r1" hasVideo="1" id="r4" src="file:///Volumes/ELT_Team_B_Clone_01/20210809_Day_041/Camera_Media/Cam_B/B168RO7O_hde/B168RO7O/B168C016_210810_RO7O/B168C016_210810_RO7O.[0696526-0697894].arx" duration="1369/24s"/>

I want to extract the text after [name="] and before [.] in each line and write it to a different text file in separate lines.

I'm working on an iMac with macOS Catalina Version 10.15.7

0 Answers
Related