Project

General

Profile

Write » History » Version 6

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