Changes

Jump to: navigation, search

Tutorial11: Sed & Awk Utilities

24 bytes added, 09:44, 4 September 2020
Using the sed Utility
'''Examples:'''
<span style="font-family:courier;">'''sed -n '3 p' text.txt''' (print 3rd line)<br>'''sed -n '1-5 p' text.txt''' (print lines 1 to 5)<br>'''sed -n '4,7 p' text.txt''' (print only lines 4 and 7)<br>'''sed -n'/^Therefore/ p' text.txt''' (print lines that begin with the patterh "Therefore")<br><br>'''sed '/^#/ d' myscript.bash ''' (remove comments at beginning of line)<br>'''sed '/exit/ q' text.txt ''' (print all lines until line containing pattern: "exit")<br>'''sed 's/this/that/' text.txt ''' (replace first occurrence of pattern "this" with "that")<br>'''sed 's/this/that/' text.txt ''' (replace ALL occurrences of pattern "this" with "that")<br><br></span>
===Using the awk Utility===
13,420
edits

Navigation menu