@@ -88,7 +88,7 @@ Testing line mode:
8888 ___xxx
8989 this is the last line
9090
91- Testing replace mode with multiple matches:
91+ Testing line mode with multiple matches:
9292
9393 $ cat > test.txt <<EOF
9494 > this is a testline
@@ -105,7 +105,7 @@ Testing replace mode with multiple matches:
105105 ___xxx
106106 this is the last line
107107
108- Testing replace mode with multiple matches and --once:
108+ Testing line mode with multiple matches and --once:
109109
110110 $ cat > test.txt <<EOF
111111 > this is a testline
@@ -122,7 +122,7 @@ Testing replace mode with multiple matches and --once:
122122 this is the foobar forth foobar line
123123 this is the last line
124124
125- Testing replace mode with multiple matches and --once-remove-match:
125+ Testing line mode with multiple matches and --once-remove-match:
126126
127127 $ cat > test.txt <<EOF
128128 > this is a testline
@@ -137,3 +137,86 @@ Testing replace mode with multiple matches and --once-remove-match:
137137 this is the second line
138138 ___xxx
139139 this is the last line
140+
141+ Testing lineinfile mode:
142+
143+ $ cat > test.txt <<EOF
144+ > this is a testline
145+ > this is the second line
146+ > this is the third foobar line
147+ > this is the last line
148+ > EOF
149+ $ goreplace --mode=lineinfile -s foobar -r ___xxx test.txt
150+ $ cat test.txt
151+ this is a testline
152+ this is the second line
153+ ___xxx
154+ this is the last line
155+
156+ Testing lineinfile mode with multiple matches:
157+
158+ $ cat > test.txt <<EOF
159+ > this is a testline
160+ > this is the second line
161+ > this is the third foobar line
162+ > this is the foobar forth foobar line
163+ > this is the last line
164+ > EOF
165+ $ goreplace --mode=lineinfile -s foobar -r ___xxx test.txt
166+ $ cat test.txt
167+ this is a testline
168+ this is the second line
169+ ___xxx
170+ ___xxx
171+ this is the last line
172+
173+ Testing lineinfile mode with multiple matches and --once:
174+
175+ $ cat > test.txt <<EOF
176+ > this is a testline
177+ > this is the second line
178+ > this is the third foobar line
179+ > this is the foobar forth foobar line
180+ > this is the last line
181+ > EOF
182+ $ goreplace --mode=lineinfile -s foobar -r ___xxx --once test.txt
183+ $ cat test.txt
184+ this is a testline
185+ this is the second line
186+ ___xxx
187+ this is the foobar forth foobar line
188+ this is the last line
189+
190+ Testing lineinfile mode with multiple matches and --once-remove-match:
191+
192+ $ cat > test.txt <<EOF
193+ > this is a testline
194+ > this is the second line
195+ > this is the third foobar line
196+ > this is the foobar forth foobar line
197+ > this is the last line
198+ > EOF
199+ $ goreplace --mode=lineinfile -s foobar -r ___xxx --once-remove-match test.txt
200+ $ cat test.txt
201+ this is a testline
202+ this is the second line
203+ ___xxx
204+ this is the last line
205+
206+ Testing lineinfile mode without match:
207+
208+ $ cat > test.txt <<EOF
209+ > this is a testline
210+ > this is the second line
211+ > this is the third foobar line
212+ > this is the foobar forth foobar line
213+ > this is the last line
214+ > EOF
215+ $ goreplace --mode=lineinfile -s barfoo -r ___xxx --once-remove-match test.txt
216+ $ cat test.txt
217+ this is a testline
218+ this is the second line
219+ this is the third foobar line
220+ this is the foobar forth foobar line
221+ this is the last line
222+ ___xxx
0 commit comments