Project

General

Profile

Write » History » Version 13

Per Amundsen, 12/30/2019 05:35 PM

1 1 Per Amundsen
_Added in 1.9.0_
2
3 10 Per Amundsen
*/write [-cidnaiNmN l<line> s<text> w<wildcard> r</regex/>] <filename> [text]*
4 1 Per Amundsen
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 10 Per Amundsen
-lN - Line number for the line to write/modify/delete.
15
-sN - Operates on a line that matches the scanned <text>.
16
-wN - Operates on a line that matches the scanned <[[Scripting_Wildcards|wildcard]]> pattern.
17 9 Per Amundsen
-r - same as -w - but uses a [[Scripting_Regex|regular expression]] match.
18 11 Per Amundsen
-mN - *TODO*
19 1 Per Amundsen
20
*Parameters*
21
22
&lt;line&gt; - The line number to find.
23 2 Per Amundsen
&lt;text&gt; - The text to scan.
24 9 Per Amundsen
&lt;wildcard&gt; - [[Scripting_Wildcards|Wildcard]] pattern to match.
25 13 Per Amundsen
&lt;/regex/&gt; - [[Scripting_Regex|Regular expression]] pattern to match.
26 3 Per Amundsen
&lt;filename&gt; - The file name to manipulate.
27
[text] - The text to be written to the file.
28 1 Per Amundsen
29
*Example*
30
31
<pre>
32
alias example {
33 8 Per Amundsen
  ; Create a file and add a few lines of text to it.
34 1 Per Amundsen
  /write Example.txt this is a cool line
35
  /write Example.txt hello there!
36
  /write Example.txt text files are cool
37
 
38 8 Per Amundsen
  ; Locate the line that starts with "hello" and insert the following text before it.
39 1 Per Amundsen
  /write -is"Hello" Example.txt This will become line 2!
40
 
41 8 Per Amundsen
  ; Delete line 1.
42 1 Per Amundsen
  /write -dl1 Example.txt
43
}
44
</pre>