Para llegar desde
P12104001;example_01_01,
P12104002;example_02_01,
P12104003;example_03_01,
P12104004;example_04_01,
a esto
P12104001;example_01_01,
<example_02_01>,
<example_03_01>,
P12104004;example_04_01,
uso
:/002/,/003/s/.*\(example_.._..\)/<\1>/
que se lee como
: Command
/Start of section/,/End of section/
s/ substitute
.* all chars up to
\(string to remember. for wild chars\)
/< with
\1 put in the remember string
>/ rest of replacement.
Use :dirección de ayuda en Vim para ver otras formas de abordar rangos de líneas.
Основываясь на моих экспериментах, кажется, что openssh
люди решили все усложнить. Следующий скрипт-оболочка может послужить источником вдохновения:
#! /bin/sh --
HNAME=${1:?## Err: Please specify the host name}
CONFD="/opt/ssh"
SOCKETS="${CONFD}/soc"
ssh -fTNF "${CONFD}/config" "${HNAME}" && {
ssh -O forward -S "${SOCKETS}/${HNAME}.socket" -TNL "${SOCKETS}/${HNAME}_mysql.socket:127.0.0.1:3306" "${HNAME}" &&\
ssh -O check -S "${SOCKETS}/${HNAME}.socket" "${HNAME}"
} || exit 1