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
Next revision Both sides next revision
linux_wiki:sed [2016/02/05 13:29]
billdozor [Remove Lines]
linux_wiki:sed [2016/03/18 23:23]
billdozor [Sed]
Line 6: Line 6:
  
 **Checklist** **Checklist**
-  * Linux distro with the 'sed' package installed+  * Distro(s): Any 
 +  * Package: 'sed' package installed
  
 ---- ----
  
-===== Insert Lines =====+====== Print Lines ====== 
 + 
 +Different ways to print specific lines. 
 + 
 +Print only line 5 pattern space<code bash>sed -n '5p' /etc/passwd</code> 
 +  * -n => silent; do not print the entire file  
 + 
 +Line 5, don't delete it<code bash>sed '5!d' /etc/passwd</code> 
 +  * !d => don't delete 
 + 
 +Print up to line 5, quit and delete the rest of the output<code bash>sed '5q;d' /etc/passwd</code> 
 +  * q => quit/stop processing more input 
 +  * d => delete the pattern space (removes all but line 5 from output) 
 + 
 +---- 
 + 
 +====== Insert Lines ======
  
 Insert lines before a found matched pattern. Insert lines before a found matched pattern.
Line 35: Line 52:
 </code> </code>
  
-==== Insert at first line ====+===== Insert at first line =====
  
 Insert also works against line numbers. Insert also works against line numbers.
Line 54: Line 71:
 ---- ----
  
-===== Append Lines =====+====== Append Lines ======
  
 Append lines after a found matched pattern. Append lines after a found matched pattern.
Line 80: Line 97:
 ---- ----
  
-===== Remove Lines =====+====== Remove Lines ======
  
 Remove lines that match a pattern. Remove lines that match a pattern.
  • linux_wiki/sed.txt
  • Last modified: 2019/05/25 23:50
  • (external edit)