2023-10-02 22:52:13 +00:00
|
|
|
.ie \n(.g .ds Aq \(aq
|
|
|
|
.el .ds Aq '
|
2023-11-08 02:19:46 +00:00
|
|
|
.TH sd 1 "sd 1.0.0"
|
2023-10-02 22:52:13 +00:00
|
|
|
.ie \n(.g .ds Aq \(aq
|
|
|
|
.el .ds Aq '
|
2023-06-04 17:54:10 +00:00
|
|
|
.SH NAME
|
|
|
|
sd
|
2023-10-02 22:52:13 +00:00
|
|
|
.ie \n(.g .ds Aq \(aq
|
|
|
|
.el .ds Aq '
|
2023-06-04 17:54:10 +00:00
|
|
|
.SH SYNOPSIS
|
2023-11-03 00:05:55 +00:00
|
|
|
\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]
|
2023-10-02 22:52:13 +00:00
|
|
|
.ie \n(.g .ds Aq \(aq
|
|
|
|
.el .ds Aq '
|
|
|
|
.SH DESCRIPTION
|
|
|
|
.ie \n(.g .ds Aq \(aq
|
|
|
|
.el .ds Aq '
|
|
|
|
.SH OPTIONS
|
2023-06-04 17:54:10 +00:00
|
|
|
.TP
|
|
|
|
\fB\-p\fR, \fB\-\-preview\fR
|
2023-11-02 22:35:39 +00:00
|
|
|
Display changes in a human reviewable format (the specifics of the format are likely to change in the future)
|
2023-06-04 17:54:10 +00:00
|
|
|
.TP
|
2023-10-02 22:52:13 +00:00
|
|
|
\fB\-F\fR, \fB\-\-fixed\-strings\fR
|
|
|
|
Treat FIND and REPLACE_WITH args as literal strings
|
|
|
|
.TP
|
2023-11-03 00:05:55 +00:00
|
|
|
\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
|
2023-10-02 22:52:13 +00:00
|
|
|
.TP
|
|
|
|
\fB\-f\fR, \fB\-\-flags\fR=\fIFLAGS\fR
|
2023-06-04 17:54:10 +00:00
|
|
|
Regex flags. May be combined (like `\-f mc`).
|
|
|
|
|
|
|
|
c \- case\-sensitive
|
2023-10-02 22:52:13 +00:00
|
|
|
|
|
|
|
e \- disable multi\-line matching
|
|
|
|
|
2023-06-04 17:54:10 +00:00
|
|
|
i \- case\-insensitive
|
2023-10-02 22:52:13 +00:00
|
|
|
|
2023-06-04 17:54:10 +00:00
|
|
|
m \- multi\-line matching
|
|
|
|
|
2023-10-02 22:52:13 +00:00
|
|
|
s \- make `.` match newlines
|
2023-06-04 17:54:10 +00:00
|
|
|
|
2023-10-02 22:52:13 +00:00
|
|
|
w \- match full words only
|
2023-06-04 17:54:10 +00:00
|
|
|
.TP
|
2023-10-02 22:52:13 +00:00
|
|
|
\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>
|
2023-11-02 22:35:39 +00:00
|
|
|
The regexp or string (if using `\-F`) to search for
|
2023-06-04 17:54:10 +00:00
|
|
|
.TP
|
2023-10-02 22:52:13 +00:00
|
|
|
<\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
|
2023-06-04 17:54:10 +00:00
|
|
|
The program panicked.
|
2023-10-02 22:52:13 +00:00
|
|
|
.ie \n(.g .ds Aq \(aq
|
|
|
|
.el .ds Aq '
|
2023-06-04 17:54:10 +00:00
|
|
|
.SH EXAMPLES
|
|
|
|
.TP
|
|
|
|
String\-literal mode
|
2023-11-10 00:03:05 +00:00
|
|
|
\fB$ echo \*(Aqlots((([]))) of special chars\*(Aq | sd \-F \*(Aq((([])))\*(Aq\fR
|
2023-06-04 17:54:10 +00:00
|
|
|
.br
|
|
|
|
lots of special chars
|
|
|
|
.TP
|
2023-10-02 22:52:13 +00:00
|
|
|
Regex use. Let\*(Aqs trim some trailing whitespace
|
|
|
|
\fB$ echo \*(Aqlorem ipsum 23 \*(Aq | sd \*(Aq\\s+$\*(Aq \*(Aq\*(Aq\fR
|
2023-06-04 17:54:10 +00:00
|
|
|
.br
|
|
|
|
lorem ipsum 23
|
|
|
|
.TP
|
|
|
|
Indexed capture groups
|
2023-10-02 22:52:13 +00:00
|
|
|
\fB$ echo \*(Aqcargo +nightly watch\*(Aq | sd \*(Aq(\\w+)\\s+\\+(\\w+)\\s+(\\w+)\*(Aq \*(Aqcmd: $1, channel: $2, subcmd: $3\*(Aq\fR
|
2023-06-04 17:54:10 +00:00
|
|
|
.br
|
|
|
|
123 dollars and 45 cents
|
|
|
|
.TP
|
|
|
|
Find & replace in file
|
2023-10-02 22:52:13 +00:00
|
|
|
\fB$ sd \*(Aqwindow.fetch\*(Aq \*(Aqfetch\*(Aq http.js\fR
|
|
|
|
.br
|
|
|
|
|
2023-06-04 17:54:10 +00:00
|
|
|
.TP
|
|
|
|
Find & replace from STDIN an emit to STDOUT
|
2023-10-02 22:52:13 +00:00
|
|
|
\fB$ sd \*(Aqwindow.fetch\*(Aq \*(Aqfetch\*(Aq < http.js\fR
|
|
|
|
.br
|
2023-06-04 17:54:10 +00:00
|
|
|
|