[[linux_wiki:sed]]

Differences

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

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
linux_wiki:sed [2016/03/19 03:23]
billdozor [Sed]
linux_wiki:sed [2019/05/26 03:50] (current)
Line 24: Line 24:
   * q => quit/stop processing more input   * q => quit/stop processing more input
   * d => delete the pattern space (removes all but line 5 from output)   * d => delete the pattern space (removes all but line 5 from output)
 +
 +----
 +
 +====== Swap Patterns ======
 +
 +Edit files by swapping pattern spaces.
 +
 +  * Before<​code bash>cat /​etc/​resolv.conf ​
 +# Generated by NetworkManager
 +search local
 +nameserver 208.67.222.222
 +nameserver 208.67.220.220</​code>​
 +  * After<​code bash>sed -i '​s/​208.67.222.222/​8.8.8.8/​g'​ /​etc/​resolv.conf ​
 +# Generated by NetworkManager
 +search local
 +nameserver 8.8.8.8
 +nameserver 208.67.220.220</​code>​
 +    * -i => In-line editing
 +    * s => swap 
 +    * g => global swap (swap every match, not just the first one)
  
 ---- ----
  • linux_wiki/sed.txt
  • Last modified: 2019/05/26 03:50
  • (external edit)