Changes

Jump to: navigation, search

OPS245 Lab 3

536 bytes removed, 18:52, 19 September 2021
m
Removing reference to here documents
|- valign="top"
|
{{Admon/tip|Bash Shell Scripting Tips:|<br>'''<u>The Here Document</u>'''<br><ul><li>A neat little trick involving a special type of redirection of stdin symbol: '''&lt;&lt;''' that allows input to be redirected to a command from within the command.<br><br> </li><li>Examples:<br><br>''cat &lt;&lt;+<br>This is a test message<br>This is the second line<br>+''<br><br>''mail -s "test message" youremailaddr &lt;&lt;+<br>This is a test message<br>I hope you like it.''<br>+<br><br>''tr [a-z] [A-Z] &lt;&lt;+<br>i like ops235<br>i love scripting.<br>+''<br><br></li></ul>'''<u>Using sed to Manipulate Text</u>'''<ul><li>The Linux command '''sed''' stands for <u>'''S'''</u>treaming <u>'''Ed'''</u>itor which is an effective way to manipulate a text file, output sent from a command, or from within a "here document". This command can manipulate matching text on a variety of criteria (such as '''line number(s)''', '''regular expression match''', etc). Commands can then be used for manipulation such as '''omitting''', '''printing''', '''substituting''', '''adding''', and '''inserting''' text.<br><br></li><li>The sed option '''-n''' suppresses display of text so the print ('''p''') command can be used; otherwise, the text will be displayed (with edits via the sed command instructions).<br><br></li><li>Results of text manipulation with sed can be stored in a variable using command substitution, or redirected to a file. '''NEVER redirect the stdout from a sed command to the same input file (or the input file will be destroyed)!''' <br><br></li><li>Examples<br><br>''sed 's/&#124;/ /g' &lt;&lt;+<br>I&#124;like&#124;weekends!<br>+''<br><br>''sed 's/$/\n/g' &lt;&lt;+<br>This text<br>should be<br>double-spaced!''<br>+<br><br></li></ul>}}
|}
932
edits

Navigation menu