파일이 있다고 가정하고 bash를 사용하여 패턴을 제거 \textcolor{red}{
하고 특정 줄 목록에서 바꾸고 싶습니다.}}
}
CatA.txt
\ParallelLText{\jverse{5}\textcolor{red}{“Ahut isi inut chili kerik abang chili rik damlo. Alangli chili kerik ahut penang achili ke tovar akungsi klolo, lapen la aphan dongpon long-lo lapen nampi avo atum vangsi chongthok-et-lo.}}{\jverse{5}\textcolor{red}{“A sower went out to sow his seed; and as he sowed, some fell on the path and was trampled on, and the birds of the air ate it up.}}
\ParallelLText{\jverse{6}\textcolor{red}{Lapen akaprek achili ke longpak athak klolo, lapen lake kechingjok pen mamat chekedulo, pima hadak longle kecham avedet-lo.}}{\jverse{6}\textcolor{red}{Some fell on the rock; and as it grew up, it withered for lack of moisture. }}
\ParallelLText{\jverse{7}\textcolor{red}{Akaprek achili ke ingsu kethe arong ajosi klolo, lapen ingsu kethe arong la pen the rap-rapsi la aphan petthip-lo.}}{\jverse{7}\textcolor{red}{Some fell among thorns, and the thorns grew with it and choked it.}}
\ParallelLText{\jverse{8}\textcolor{red}{Jisu halatum aphan thak-lo, “Arnam Arat akepatu alam kechiniji, lake nangtum aphan nangpitang-lo, bonta akaprek atum aphan ke lamlir pensi thanlo. Lasi latum thek longbom setta thek longledetji lapen arjubom setta chini nedetji.” }}{\jverse{8}\textcolor{red}{He said, “To you it has been given to know the secrets of the kingdom of God; but to others I speak in parables, so that‘looking they may not perceive, and listening they may not understand.’}}
\ParallelLText{\jverse{9}\textcolor{red}{“Bonta Lamlir athe lahelo: Chili ke Arnam alamlo.}}{\jverse{9}\textcolor{red}{“Now the parable is this: The seed is the word of God.}}
\ParallelLText{\jverse{10}\textcolor{red}{Tovar akung keklo achili ke karjulong atumlo; latum kroikredetsi kejok kelongledetji aphan Diabol vangsi halatum aning arlo pen alam pondet-lo.}}{\jverse{10}\textcolor{red}{The ones on the path are those who have heard; then the devil comes and takes away the word from their hearts, so that they may not believe and be saved.}}
패턴을 제거하려는 행 목록이 행 1과 행 3이라고 가정해 보겠습니다. 따라서 패턴을 제거하고 교체한 후 최종 출력은 다음과 같습니다.
\ParallelLText{\jverse{5}“Ahut isi inut chili kerik abang chili rik damlo. Alangli chili kerik ahut penang achili ke tovar akungsi klolo, lapen la aphan dongpon long-lo lapen nampi avo atum vangsi chongthok-et-lo.}{\jverse{5}“A sower went out to sow his seed; and as he sowed, some fell on the path and was trampled on, and the birds of the air ate it up.}
\ParallelLText{\jverse{6}\textcolor{red}{Lapen akaprek achili ke longpak athak klolo, lapen lake kechingjok pen mamat chekedulo, pima hadak longle kecham avedet-lo.}}{\jverse{6}\textcolor{red}{Some fell on the rock; and as it grew up, it withered for lack of moisture. }}
\ParallelLText{\jverse{7}Akaprek achili ke ingsu kethe arong ajosi klolo, lapen ingsu kethe arong la pen the rap-rapsi la aphan petthip-lo.}{\jverse{7}Some fell among thorns, and the thorns grew with it and choked it.}
\ParallelLText{\jverse{8}\textcolor{red}{Jisu halatum aphan thak-lo, “Arnam Arat akepatu alam kechiniji, lake nangtum aphan nangpitang-lo, bonta akaprek atum aphan ke lamlir pensi thanlo. Lasi latum thek longbom setta thek longledetji lapen arjubom setta chini nedetji.” }}{\jverse{8}\textcolor{red}{He said, “To you it has been given to know the secrets of the kingdom of God; but to others I speak in parables, so that‘looking they may not perceive, and listening they may not understand.’}}
\ParallelLText{\jverse{9}\textcolor{red}{“Bonta Lamlir athe lahelo: Chili ke Arnam alamlo.}}{\jverse{9}\textcolor{red}{“Now the parable is this: The seed is the word of God.}}
\ParallelLText{\jverse{10}\textcolor{red}{Tovar akung keklo achili ke karjulong atumlo; latum kroikredetsi kejok kelongledetji aphan Diabol vangsi halatum aning arlo pen alam pondet-lo.}}{\jverse{10}\textcolor{red}{The ones on the path are those who have heard; then the devil comes and takes away the word from their hearts, so that they may not believe and be saved.}}
이 명령을 사용해 보았지만 작동하지 않습니다
VAR=\\texcolor{red}{
sed -i "1s/$VAR//;3s/$VAR//" A.txt
모든 행에서 패턴을 제거하는 방법을 알고 있지만 특정 행에 대해서는 모릅니다.
답변1
@steeldriver가 말했듯이, 올바르게 이스케이프되도록 하려면 다음과 같이 4개의 백슬래시를 사용해야 합니다 VAR="\\\\textcolor{red}{"
. 명령은 sed
변경 없이 작동합니다. 또한 "textcolor"의 철자가 틀렸습니다.
답변2
다음 awk 명령을 사용하여 테스트하면 잘 작동합니다.
awk 'NR==1||3{gsub(/\\textcolor{red}/,"",$0);print $0}' filename
산출
\ParallelLText{\jverse{5}{“Ahut isi inut chili kerik abang chili rik damlo. Alangli chili kerik ahut penang achili ke tovar akungsi klolo, lapen la aphan dongpon long-lo lapen nampi avo atum vangsi chongthok-et-lo.}}{\jverse{5}{“A sower went out to sow his seed; and as he sowed, some fell on the path and was trampled on, and the birds of the air ate it up.}}
\ParallelLText{\jverse{6}{Lapen akaprek achili ke longpak athak klolo, lapen lake kechingjok pen mamat chekedulo, pima hadak longle kecham avedet-lo.}}{\jverse{6}{Some fell on the rock; and as it grew up, it withered for lack of moisture. }}
\ParallelLText{\jverse{7}{Akaprek achili ke ingsu kethe arong ajosi klolo, lapen ingsu kethe arong la pen the rap-rapsi la aphan petthip-lo.}}{\jverse{7}{Some fell among thorns, and the thorns grew with it and choked it.}}
\ParallelLText{\jverse{8}{Jisu halatum aphan thak-lo, “Arnam Arat akepatu alam kechiniji, lake nangtum aphan nangpitang-lo, bonta akaprek atum aphan ke lamlir pensi thanlo. Lasi latum thek longbom setta thek longledetji lapen arjubom setta chini nedetji.” }}{\jverse{8}{He said, “To you it has been given to know the secrets of the kingdom of God; but to others I speak in parables, so that‘looking they may not perceive, and listening they may not understand.’}}
\ParallelLText{\jverse{9}{“Bonta Lamlir athe lahelo: Chili ke Arnam alamlo.}}{\jverse{9}{“Now the parable is this: The seed is the word of God.}}
\ParallelLText{\jverse{10}{Tovar akung keklo achili ke karjulong atumlo; latum kroikredetsi kejok kelongledetji aphan Diabol vangsi halatum aning arlo pen alam pondet-lo.}}{\jverse{10}{The ones on the path are those who have heard; then the devil comes and takes away the word from their hearts, so that they may not believe and be saved.}}
프라빈@프라빈:~$