I have a sorted list of phrases, list.txt. I want use awk to strip any entry on that list from a lengthy file of prose, and replace it with a return. It's not hard to find examples of using awk to compare two files, but they all assume both are neatly structured, which prose is not.
Here's the relevant part of the script:
#! /bin/sh
...
sed '
s/[0-9]/\n/g # strip out all numbers, replace with returns
s/[@€•\!¡%“”"_–=\*\&\/\?¿\,\.]/\n/g
' $1 > $1.z.tmp
cp stowplist.txt strip1.tmp
awk 'BEGIN { FS = "\t" } ; { print $1 }' SpanishGlossary.utf8 >> strip1.tmp
#sh ./awkwords SpanishGlossary.utf8 >> strip1.tmp
sort -u strip1.tmp > strip2.tmp
awk '{ print length(), $0 | "sort -rn" }' strip2.tmp > strip3.tmp
#echo "List ordered by length."
#echo "Now creating new script." # THIS AFFECTS THE SCRIPT, NOT THE OUTPUT FILE.
sed '
s/[0-9]//g # strip out all numbers
s/[\t^\ *\ $]// # strip tabs, leading and trailing spaces
/^.\{0,5\}$/d # delete lines with less than five characters
/^$/d # delete blank lines
s/^/\\y/g # begin word boundary
s/$/\\y/g #end word boundary
s/\ /\\ /g # make spaces into literals
' strip3.tmp > strip.tmp
echo "Eliminating existing entries. This may take a while."
awk 'NR==FNR{p = p s $0; s="|" ;next} {gsub(p,"\n");print}' strip.tmp $1.z.tmp > $1.1.tmp
...
And here's a representative sample of strip.tmp:
\yinfraestructura\ de\ la\ fabricación\y
\yFecha\ de\ Vencimiento\ del\ Contrato\y
\yfactores\ importantes\ a\ considerar\y
\yexcepto\ lo\ estrictamente\ personal\y
\yexamen\ de\ los\ ojos\ con\ dilatación\y
\yes\ un\ estado\ capitalista\ corrupto\y
\yes\ un\ derecho\ legal\ reconocido\ en\y
\yestimular\ la\ capacidad\ productiva\y
\yestimación\ de\ la\ edad\ gestacional\y
\yEste\ Programa\ de\ Transición\ Verde\y
\yEstán\ permanentemente\ enfrentados\y
And finally, a representative sample of the input text, with punctuation substituted with line breaks.
Es la historia de más de un siglo del cooperativismo en Argentina
con empresas en todos los rincones de nuestra geografía y en todos los sectores de la economía
En plena crisis del sistema económico mundial
con creciente alarma frente al deterioro a escala planetaria de las condiciones medio ambientales
la comunidad internacional ha declarado
desde la Organización de las Naciones Unidas
a éste como el Año Internacional de las Cooperativas
No es casualidad
el mundo está buscando nuevos caminos
nuevos paradigmas para organizarse