1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
|
.ie \n(.g .ds Aq \(aq
.el .ds Aq '
.TH sd 1 "sd 1.0.0"
.ie \n(.g .ds Aq \(aq
.el .ds Aq '
.SH NAME
sd
.ie \n(.g .ds Aq \(aq
.el .ds Aq '
.SH SYNOPSIS
\fBsd\fR [\fB\-p\fR|\fB\-\-preview\fR] [\fB\-F\fR|\fB\-\-fixed\-strings\fR] [\fB\-n\fR|\fB\-\-max\-replacements\fR] [\fB\-f\fR|\fB\-\-flags\fR] [\fB\-h\fR|\fB\-\-help\fR] [\fB\-V\fR|\fB\-\-version\fR] <\fIFIND\fR> <\fIREPLACE_WITH\fR> [\fIFILES\fR]
.ie \n(.g .ds Aq \(aq
.el .ds Aq '
.SH DESCRIPTION
.ie \n(.g .ds Aq \(aq
.el .ds Aq '
.SH OPTIONS
.TP
\fB\-p\fR, \fB\-\-preview\fR
Display changes in a human reviewable format (the specifics of the format are likely to change in the future)
.TP
\fB\-F\fR, \fB\-\-fixed\-strings\fR
Treat FIND and REPLACE_WITH args as literal strings
.TP
\fB\-n\fR, \fB\-\-max\-replacements\fR=\fILIMIT\fR [default: 0]
Limit the number of replacements that can occur per file. 0 indicates unlimited replacements
.TP
\fB\-f\fR, \fB\-\-flags\fR=\fIFLAGS\fR
Regex flags. May be combined (like `\-f mc`).
c \- case\-sensitive
e \- disable multi\-line matching
i \- case\-insensitive
m \- multi\-line matching
s \- make `.` match newlines
w \- match full words only
.TP
\fB\-h\fR, \fB\-\-help\fR
Print help (see a summary with \*(Aq\-h\*(Aq)
.TP
\fB\-V\fR, \fB\-\-version\fR
Print version
.TP
<\fIFIND\fR>
The regexp or string (if using `\-F`) to search for
.TP
<\fIREPLACE_WITH\fR>
What to replace each match with. Unless in string mode, you may use captured values like $1, $2, etc
.TP
[\fIFILES\fR]
The path to file(s). This is optional \- sd can also read from STDIN.
Note: sd modifies files in\-place by default. See documentation for examples.
.ie \n(.g .ds Aq \(aq
.el .ds Aq '
.SH "EXIT STATUS"
.IP 0
Successful program execution.
.IP 1
Unsuccessful program execution.
.IP 101
The program panicked.
.ie \n(.g .ds Aq \(aq
.el .ds Aq '
.SH EXAMPLES
.TP
String\-literal mode
\fB$ echo \*(Aqlots((([]))) of special chars\*(Aq | sd \-s \*(Aq((([])))\*(Aq\fR
.br
lots of special chars
.TP
Regex use. Let\*(Aqs trim some trailing whitespace
\fB$ echo \*(Aqlorem ipsum 23 \*(Aq | sd \*(Aq\\s+$\*(Aq \*(Aq\*(Aq\fR
.br
lorem ipsum 23
.TP
Indexed capture groups
\fB$ echo \*(Aqcargo +nightly watch\*(Aq | sd \*(Aq(\\w+)\\s+\\+(\\w+)\\s+(\\w+)\*(Aq \*(Aqcmd: $1, channel: $2, subcmd: $3\*(Aq\fR
.br
123 dollars and 45 cents
.TP
Find & replace in file
\fB$ sd \*(Aqwindow.fetch\*(Aq \*(Aqfetch\*(Aq http.js\fR
.br
.TP
Find & replace from STDIN an emit to STDOUT
\fB$ sd \*(Aqwindow.fetch\*(Aq \*(Aqfetch\*(Aq < http.js\fR
.br
|