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/02/11 22:29]
billdozor [Print Lines]
linux_wiki:sed [2016/03/28 22:06]
billdozor [Print Lines]
Line 6: Line 6:
  
 **Checklist** **Checklist**
-  * Linux distro with the 'sed' package installed+  * Distro(s): Any 
 +  * Package: 'sed' package installed
  
 ---- ----
Line 23: 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/25 23:50
  • (external edit)