quickreference:unix
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revision | |||
| quickreference:unix [2024/03/04 15:54] – rodolico | quickreference:unix [2025/02/05 00:12] (current) – [Shell (mainly BASH)] rodolico | ||
|---|---|---|---|
| Line 237: | Line 237: | ||
| ===== Shell (mainly BASH) ===== | ===== Shell (mainly BASH) ===== | ||
| + | ==== Here Documents ==== | ||
| + | |||
| + | Most unix users are familiar with echo' | ||
| + | |||
| + | A **here document** is a way of having multiple lines processed at one time. In many cases, you can have similar functionality using quotes, but here documents are more robust. | ||
| + | |||
| + | For example, a simple test of a newly built mail system might include creating a file with all of the headers necessary, then passing that to // | ||
| + | |||
| + | <code bash> | ||
| + | sendmail user@example.com << EOF | ||
| + | To: user@example.com | ||
| + | from: root@example.org | ||
| + | Subject: test | ||
| + | |||
| + | This is a test | ||
| + | EOF | ||
| + | </ | ||
| + | |||
| + | The entire block above is one command. Here is the breakdown. | ||
| + | |||
| + | - //sendmail user@example.com// | ||
| + | - //<<// | ||
| + | - //EOF// is the tag which will mark the end of the text for the here document | ||
| + | - Everything up to the EOF is the actual string to be passed to sendmail | ||
| + | - //EOF// at the end marks the end of the here document. **Note**: there must be no leading or trailing whitespace. The tag must be exactly as entered after the << (case sensitive), and must be the only thing on the final line. | ||
| + | |||
| + | This only touches the surface of here documents. See [[https:// | ||
| ==== Find files within date range containing text ==== | ==== Find files within date range containing text ==== | ||
quickreference/unix.txt · Last modified: 2025/02/05 00:12 by rodolico
