Project

General

Profile

Write » History » Version 8

Per Amundsen, 08/13/2015 10:26 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 7 Per Amundsen
-d - Deletes the given or last 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 8 Per Amundsen
-r - same as -w - but uses a [[Scripting_Regex|regular expression]] match.
18 1 Per Amundsen
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 8 Per Amundsen
  ; Create a file and add a few lines of text to it.
33 1 Per Amundsen
  /write Example.txt this is a cool line
34
  /write Example.txt hello there!
35
  /write Example.txt text files are cool
36
 
37 8 Per Amundsen
  ; Locate the line that starts with "hello" and insert the following text before it.
38 1 Per Amundsen
  /write -is"Hello" Example.txt This will become line 2!
39
 
40 8 Per Amundsen
  ; Delete line 1.
41 1 Per Amundsen
  /write -dl1 Example.txt
42
}
43
</pre>