Il giorno gio 20 apr 2017 alle 11:22, k...@aspodata.se ha scritto:
Frederico Bruni:
...
Enter Documentation/it/notation and run this:
#!/bin/bash
LIST="$(grep -oh -e @ref{.*} *.itely | sort -u)"
for i in $LIST; do
echo $i
# echo -n "Replace" $i "with the translated node: "
# read NODE
# if $NODE=""; then exit
# else
# sed "s|$i|$NODE|g" *.itely
# fi
done
This doesn't work:
$ LIST="$(grep -oh -e @ref{.*} *.itely | sort -u)"
$ echo $LIST
This is better but messes with newlines:
$ LIST=$(grep -oh -e "@ref{.*}" *.itely | sort -u)
$ echo $LIST
@ref{Accidentals} @ref{Align} @ref{Aligning lyrics to a melody [...]
The "for i in $LIST" also messes with newlines.
This will rid you of the newline problem:
$ grep -oh -e "@ref{.*}" *.itely | sort -u | while read i; do echo
$i; done
@ref{Accidentals}
@ref{Align}
...
but now "read NODE" won't read from script stdin. Trying with
/dev/stdin doesn't help since stdin is from the pipe, not the script
stdin.
yes, this is a problem...
$ grep -oh -e "@ref{.*}" *.itely | sort -u |
while read i; do echo $i; read NODE < /dev/stdin; echo $b; break;
done
@ref{Accidentals}
@ref{Align}
you culd solve that with arrays:
$ cat tt
#!/bin/sh
# for some reason mapfile doesnt work on pipes, hence the tmpfile
grep -oh -e "@ref{.*}" *.itely | sort -u > tmpfile
mapfile -t org < tmpfile
len=${#org[@]}
for (( ix=0; ix < $len; ix++ ))
do
read NODE
printf "%4d: %s %s\n" $ix "${org[ix]}" "$NODE"
done
Unfortunately this script hangs forever.
I guess I'll have to revert to my almost manual replacement I've used
so far.
$ ./tt | head -5
a d
0: @ref{Accidentals} a d
cd g
1: @ref{Align} cd g
gv
2: @ref{Aligning lyrics to a melody} gv
xcvb rge
3: @ref{Aligning objects} xcvb rge
rtdfg gr
4: @ref{Ambitus} rtdfg gr
2
$
you could also do the for loop like:
for i in "${org[@]}"
do
read NODE
echo $i $NODE
done
Regards,
/Karl Hammar
-----------------------------------------------------------------------
Aspö Data
Lilla Aspö 148
S-742 94 Östhammar
Sweden
+46 173 140 57
_______________________________________________
lilypond-devel mailing list
lilypond-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-devel
_______________________________________________
lilypond-devel mailing list
lilypond-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-devel