Мне нужно выполнить несколько операций над несколькими строками, чтобы очистить их. Я был в состоянии сделать это, но в нескольких операциях в bash
as,
# Getting the Content between START and END
var1=$(sed '/START/,/END/!d;//d' <<< "$content")
# Getting the 4th Line
var2=$(sed '4q;d' <<< "$content")
# Stripping all the new lines
var1=${var1//$'\n'/}
var2=${var2//$'\n'/}
# Escaping the double quotes i.e. A"B => A\"B
var1=$(sed "s/\"/\\\\\"/g" <<< "$var1")
var2=$(sed "s/\"/\\\\\"/g" <<< "$var2")
# Removing the contents wrapped in brackets i.e. A[...]B => AB
var1=$(sed -e 's/\[[^][]*\]//g' <<< "$var1")
var2=$(sed -e 's/\[[^][]*\]//g' <<< "$var2")
Нет сомнений, что очень плохо читать одно и то же снова и снова, когда одно и то же можетбыть сделано в одной операции. Любые предложения?
Рабочий пример:
SAMPLE INPUT
[1][INTRO]
[2][NAV]
ABAQUESNE, Masséot
...
START
French ceramist, who was the first grand-master of the glazed pottery
at Sotteville-ls-Rouen (20 years before [8]Bernard Palissy). He took
part in the development of the ceramic factory of Rouen. He was the
author - among others - of the ceramic triptych representing the Flood
(1550, couen, Muse de la Renaissance).
END
DESIRED OUTPUT
ABAQUESNE, Masséot
French ceramist, who was the first grand-master of the glazed pottery at Sotteville-ls-Rouen (20 years before Bernard Palissy). He took part in the development of the ceramic factory of Rouen. He was the author - among others - of the ceramic triptych representing the Flood (1550, couen, Muse de la Renaissance).