Write » History » Version 1
Per Amundsen, 02/15/2014 06:31 PM
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 | <filename> - The file name to manipulate. |
||
20 | [text] - The text to be written to the file. |
||
21 | <line> - The line number to find. |
||
22 | s<text> - The text to scan. |
||
23 | <wildcard> - Wildcard pattern to match. |
||
24 | </regex/> - Regex pattern to match. |
||
25 | |||
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> |