Project

General

Profile

Write » History » Version 3

Per Amundsen, 02/25/2014 06:21 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
-n - Prevent adding $crlf at the end of the text.
11
-a - Appends the text to an existing line.
12
-l - Line number for the line to write/modify/delete.
13
-s - Operates on a file that matched a the scanned <text>.
14
-w - Operates on a file that matched a the scanned <wildcard> pattern.
15
-r - same as -w - but uses a regular expression match.
16
17
*Parameters*
18
19
&lt;line&gt; - The line number to find.
20 2 Per Amundsen
&lt;text&gt; - The text to scan.
21 1 Per Amundsen
&lt;wildcard&gt; - Wildcard pattern to match.
22
&lt;/regex/&gt; - Regex pattern to match.
23 3 Per Amundsen
&lt;filename&gt; - 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>