Write » History » Version 5
  Per Amundsen, 02/25/2014 06:23 AM 
  
| 1 | 1 | Per Amundsen | _Added in 1.9.0_ | 
|---|---|---|---|
| 2 | |||
| 3 | */write [-cidna l<line> s<text> w<wildcard> r</regex/>] <filename> [text]* | ||
| 4 | |||
| 5 | *Switches* | ||
| 6 | |||
| 7 | -c - Clears the entire file before writing to it. | ||
| 8 | -i - Inserts the text at a given line instead of replacing it. | ||
| 9 | -d - Deletes the given line. | ||
| 10 | 5 | Per Amundsen | -n - Prevent adding [[$crlf]] at the end of the text. | 
| 11 | 1 | Per Amundsen | -a - Appends the text to an existing line. | 
| 12 | -l - Line number for the line to write/modify/delete. | ||
| 13 | 4 | Per Amundsen | -s - Operates on a line that matches the scanned <text>. | 
| 14 | -w - Operates on a line that matches the scanned <wildcard> pattern. | ||
| 15 | 1 | Per Amundsen | -r - same as -w - but uses a regular expression match. | 
| 16 | |||
| 17 | *Parameters* | ||
| 18 | |||
| 19 | <line> - The line number to find. | ||
| 20 | 2 | Per Amundsen | <text> - The text to scan. | 
| 21 | 1 | Per Amundsen | <wildcard> - Wildcard pattern to match. | 
| 22 | </regex/> - Regex pattern to match. | ||
| 23 | 3 | Per Amundsen | <filename> - The file name to manipulate. | 
| 24 | [text] - The text to be written to the file. | ||
| 25 | 1 | Per Amundsen | |
| 26 | *Example* | ||
| 27 | |||
| 28 | <pre> | ||
| 29 | alias example { | ||
| 30 | ;Create a file; add a few lines of text to it. | ||
| 31 | /write Example.txt this is a cool line | ||
| 32 | /write Example.txt hello there! | ||
| 33 | /write Example.txt text files are cool | ||
| 34 | |||
| 35 | ;Locate the line that starts with "hello" and insert the following text before it. | ||
| 36 | /write -is"Hello" Example.txt This will become line 2! | ||
| 37 | |||
| 38 | ;Delete line 1. | ||
| 39 | /write -dl1 Example.txt | ||
| 40 | } | ||
| 41 | </pre> |