#!/usr/bin/sed # finger.sed -- put fingering on line after notes # every other line has fingering. Strictly. Spaces # are the extra spacers. Fill fingering lines # %S% at end is good s/ *$// #clean ends of lines s/^ *// # 'N' joins with newlines \n N #don't mess with lines w/o fingering /\n *$/b fin # single space notes lines after loop below # put lots of spaces on ends of lines # use 'begin' as a counter s/^/%begin%/ :loop s/%begin% *\([^ ]*\)/\1 %begin%/ s/$/ %S% %S%/ /\n.*%begin%/! b loop s/%begin%// :top s/\(\n.*\) /\1 %S% / # sub esses for extra spaces in second lines / /b top :again #p # print here good for debug s/\([^ ]*\)\(.*\)\n *\([^ ]*\) \([^ ]*\)\(.*\)/\2\n\5 \3 \1\4/ # 1. 2. ^ 3. 4. 5. # 1= first word 2= rest up to newline # 3= not spcs after new line 4= word after that # 5= rest of line. s/^ *// s/ *$// # end when notes, words of first line, are used up /^\n/t fin b again :fin s/%S%//g s/^\n// s/\n/\ / s/ */ /g s/ *$// #clean ends of lines s/^ *//