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.
$ 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
address@hidden
for (( ix=0; ix < $len; ix++ ))
do
read NODE
printf "%4d: %s %s\n" $ix "${org[ix]}" "$NODE"
done