Write » History » Revision 1
Revision 1/15
| Next »
Per Amundsen, 02/15/2014 06:31 PM
Added in 1.9.0
/write [-cidna l<line> s<text> w<wildcard> r</regex/>] <filename> [text]
Switches
-c - Clears the entire file before writing to it.
-i - Inserts the text at a given line instead of replacing it.
-d - Deletes the given line.
-n - Prevent adding $crlf at the end of the text.
-a - Appends the text to an existing line.
-l - Line number for the line to write/modify/delete.
-s - Operates on a file that matched a the scanned <text>.
-w - Operates on a file that matched a the scanned <wildcard> pattern.
-r - same as -w - but uses a regular expression match.
Parameters
<filename> - The file name to manipulate.
[text] - The text to be written to the file.
<line> - The line number to find.
s<text> - The text to scan.
<wildcard> - Wildcard pattern to match.
</regex/> - Regex pattern to match.
Example
alias example { ;Create a file; add a few lines of text to it. /write Example.txt this is a cool line /write Example.txt hello there! /write Example.txt text files are cool ;Locate the line that starts with "hello" and insert the following text before it. /write -is"Hello" Example.txt This will become line 2! ;Delete line 1. /write -dl1 Example.txt }
Updated by Per Amundsen almost 11 years ago · 1 revisions