FastHandle - IT Operations Examples

FastHandle is fast operation tools for infrastructure configurations and tests.

User Tools

Site Tools


appendix:sed.html



Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
appendix:sed.html [2018/02/02 00:32]
kurihara created
appendix:sed.html [2020/02/28 23:14] (current)
kurihara [Insert row]
Line 10: Line 10:
  
  
 +\\ 
 +\\
 ===== Example ===== ===== Example =====
-==== Line Delete ====+==== Delete row====
  
 <sxh bash toolbar:false gutter:false> <sxh bash toolbar:false gutter:false>
Line 28: Line 29:
 </sxh> </sxh>
  
-==== Line Append ====+\\ 
 +==== Append row==== 
 +<sxh bash toolbar:false gutter:false> 
 +$ cat test.txt 
 +123 
 +456 
 +abc 
 +def 
 +$ cat test.txt | sed -e "/456/a 789" 
 +123 
 +456 
 +789 
 +abc 
 +def 
 +</sxh> 
 + 
 + 
 +\\ 
 +==== Insert row==== 
 +<sxh bash toolbar:false gutter:false> 
 +$ cat test.txt 
 +123ab 
 +456ab 
 +abcab 
 +defab 
 +$ cat test.txt | sed -e "/456/i aaa" 
 +123ab 
 +aaa 
 +456ab 
 +abcab 
 +defab 
 +</sxh> 
 + 
 +\\ 
 +==== Substitution ==== 
 +<sxh bash toolbar:false gutter:false> 
 +$ cat test.txt 
 +123 
 +456 
 +abc 
 +def 
 +$ cat test.txt | sed 's/456/789/g' 
 +123 
 +789 
 +abc 
 +def 
 +</sxh> 
 + 
 +<sxh bash toolbar:false gutter:false> 
 +$  cat test.txt 
 +Defaults          requiretty 
 +$ cat test.txt |sed 's/Defaults.*requiretty/#Default\trequiretty/g' 
 +#Default        requiretty 
 +</sxh> 
 + 
 +\\ 
 +=== Replace if matched=== 
 +<sxh bash toolbar:false gutter:false> 
 +sed -i '/disable/ s/yes/no/' /etc/xinetd.d/tftp" 
 +</sxh>
  
  
-==== Line Insert ====+\\ 
 +==== Reuse ==== 
 +If it is enclosed by \(target character string \), it is partially reused such as \1, \2, \3, ... of the replaced character string
  
  


appendix/sed.html.1517499168.txt.gz · Last modified: 2018/02/02 00:32 by kurihara