13,420
edits
Changes
no edit summary
|- valign="top"
|
{{Admon/tip|Bash Shell Scripting Tips:|<br><ul><li>'''The Here Document'''<br><br>A neat little trick involving a special type of redirection of stdin ( '''<<''' ) that allows input to be redirected to a command from within the command. '''The name relates to where the stdin is contained: not in a file, but "here in the command itself"'''. A character (like '''+''') is used to mark the boundary of stdin. It is important that the ending boundary only contains a line with that matching character (eg '''+'''); otherwise the stdin will continue to be read! This command is a convenience way to display multiple lines on that screen, but this command can be used with any Linux command that accept stdin.<br><br><u>'''Examples''' (try at the shell prompt)</u><br><br>''cat <<+<br>This is a test message<br>This is the second line<br>+''<br><br>''mail -s "test message" youremailaddr <<+<br>This is a test message<br>I hope you like it.''<br>+<br><br>''tr [a-z] [A-Z] <<+<br>i like ops235<br>i love scripting.<br>+''<br><br></li><li>'''Using sed to Manipulate Text'''<br><br>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, regular expression match, etc). Commands can then be used for manipulation such as omitting, printing, substituting, adding, inserting, etc. 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>'''<u>Examples''' (try at the shell prompt)</u><br><br>''sed 's/||/ /g' <<+<br>I||like||weekends!<br>+''<br><br></li></ul>}}
|}