-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathstring.1.html
226 lines (224 loc) · 5.84 KB
/
string.1.html
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
<!DOCTYPE html>
<html>
<head>
<title>Caltech Library's Digital Library Development Sandbox</title>
<link href='https://fonts.googleapis.com/css?family=Open+Sans' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="/css/site.css">
</head>
<body>
<header>
<a href="http://library.caltech.edu"><img src="/assets/liblogo.gif" alt="Caltech Library logo"></a>
</header>
<nav>
<ul>
<li><a href="/">Home</a></li>
<li><a href="./">README</a></li>
<li><a href="LICENSE">LICENSE</a></li>
<li><a href="INSTALL.html">INSTALL</a></li>
<li><a href="user-manual.html">User Manual</a></li>
<li><a href="how-to/">Tutorials</a></li>
<li><a href="search.html">Search Docs</a></li>
<li><a href="about.html">About</a></li>
<li><a href="https://github.com/caltechlibrary/datatools">GitHub</a></li>
</ul>
</nav>
<section>
<h1 id="name">NAME</h1>
<p>string</p>
<h1 id="synopsis">SYNOPSIS</h1>
<p>string <a href="#options">OPTIONS</a> [VERB] [VERB PARAMETERS…]</p>
<h1 id="description">DESCRIPTION</h1>
<p>string is a command line tool for transforming strings in common
ways.</p>
<ul>
<li>string length</li>
<li>changing cases</li>
<li>checking for prefixes, suffixes</li>
<li>trimming prefixes, suffixes and cutsets (i.e. list of characters to
cut)</li>
<li>position, counting and replacing substrings</li>
<li>splitting a string into a JSON array of strings, joining JSON a
string arrays into a string</li>
</ul>
<p>VERB refers to the operation to performed on the supplied string(s).
VER PARAMETERS are thsose additional terms need to complete the process
provided by the VERB.</p>
<h1 id="options">OPTIONS</h1>
<p>Options always come before the VERB.</p>
<dl>
<dt>-help</dt>
<dd>
display help
</dd>
</dl>
<p>-license :display license</p>
<dl>
<dt>-version</dt>
<dd>
display version
</dd>
<dt>-d, -delimiter</dt>
<dd>
set the delimiter
</dd>
<dt>-do, -output-delimiter</dt>
<dd>
set the output delimiter
</dd>
<dt>-i, -input</dt>
<dd>
input file name
</dd>
<dt>-nl, -newline</dt>
<dd>
if true add a trailing newline
</dd>
<dt>-o, -output</dt>
<dd>
output file name
</dd>
<dt>-quiet</dt>
<dd>
suppress error messages
</dd>
</dl>
<h2 id="verbs">VERBS</h2>
<dl>
<dt>contains</dt>
<dd>
has substrings: SUBSTRING [STRING]
<code>string contains SUBSTRING [STRING]</code>
</dd>
<dt>count</dt>
<dd>
count substrings: SUBSTRING [STRING]
<code>string count SUBSTRING [STRING]</code>
</dd>
<dt>englishtitle</dt>
<dd>
English style title case: [STRING]
<code>string englishtitle [STRING]</code>
</dd>
<dt>hasprefix</dt>
<dd>
true/false on prefix: PREFIX [STRING]
<code>string hasprefix PREFIX [STRING]</code>
</dd>
<dt>hassuffix</dt>
<dd>
true/false on suffix: SUFFIX [STRING]
<code>string hassuffix SUFFIX [STRING]</code>
</dd>
<dt>join</dt>
<dd>
join JSON array into string: DELIMITER [JSON_ARRAY]
<code>string join DELIMITER [JSON_ARRAY]</code>
</dd>
<dt>length</dt>
<dd>
length of string: [STRING] <code>string length [STRING]</code>
</dd>
<dt>padleft</dt>
<dd>
left pad PADDING MAX_LENGTH [STRING]
<code>string padleft PADDING MAX_LENGTH [STRING]</code>
</dd>
<dt>padright</dt>
<dd>
right pad PADDING MAX_LENGTH [STRING]
<code>string padright PADDING MAX_LENGTH [STRING]</code>
</dd>
<dt>position</dt>
<dd>
position of substring: SUBSTRING [STRING]
<code>string position SUBSTRING [STRING]</code>
</dd>
<dt>replace</dt>
<dd>
replace: OLD NEW [STRING] <code>string replace OLD NEW [STRING]</code>
</dd>
<dt>replacen</dt>
<dd>
replace n times: OLD NEW N [STRING]
<code>string replacen OLD NEW N [STRING]</code>
</dd>
<dt>slice</dt>
<dd>
copy a substring: START END [STRING]
<code>string slice START END [STRING]</code>
</dd>
<dt>split</dt>
<dd>
split into a JSON array: DELIMITER [STRING]
<code>string split DELIMITER [STRING]</code>
</dd>
<dt>splitn</dt>
<dd>
split into an N length JSON array: DELIMITER N [STRING]
<code>string splitn DELIMITER N [STRING]</code>
</dd>
<dt>tolower</dt>
<dd>
to lower case: [STRING] <code>string tolower [STRING]</code>
</dd>
<dt>totitle</dt>
<dd>
to title case: [STRING] <code>string totitle [STRING]</code>
</dd>
<dt>toupper</dt>
<dd>
to upper case: [STRING] <code>string toupper [STRING]</code>
</dd>
<dt>trim</dt>
<dd>
trim (beginning and end), CUTSET [STRING]
<code>string trim CURSET [STRING]</code>
</dd>
<dt>trimleft</dt>
<dd>
left trim CUTSET [STRING] <code>string trimleft CUTSET [STRING]</code>
</dd>
<dt>trimprefix</dt>
<dd>
trims prefix: PREFIX [STRING]
<code>string trimprefix PREFIX [STRING]</code>
</dd>
<dt>trimright</dt>
<dd>
right trim: CUTSET [STRING]
<code>string trimright CUTSET [STRING]</code>
</dd>
<dt>trimspace</dt>
<dd>
trim leading and trailing spaces: [STRING]
<code>string trimspace [STRING]</code>
</dd>
<dt>trimsuffix</dt>
<dd>
trim suffix: SUFFIX [STRING]
<code>string trimsuffix SUFFIX [STRING]</code>
</dd>
</dl>
<h1 id="examples">EXAMPLES</h1>
<p>Convert text to upper case</p>
<pre><code> string toupper "one"</code></pre>
<p>Convert text to lower case</p>
<pre><code> string tolower "ONE"</code></pre>
<p>Captialize an English phrase</p>
<pre><code> string englishtitle "one more thing to know"</code></pre>
<p>Split a space newline delimited list of words into a JSON array</p>
<pre><code> string -i wordlist.txt split "\n"</code></pre>
<p>Join a JSON array of strings into a newline delimited list</p>
<pre><code> string join '\n' '["one","two","three","four","five"]'</code></pre>
<p>string 1.2.12</p>
</section>
<footer>
<span><h1><A href="http://caltech.edu">Caltech</a></h1></span>
<span>© 2023 <a href="https://www.library.caltech.edu/copyright">Caltech library</a></span>
<address>1200 E California Blvd, Mail Code 1-32, Pasadena, CA 91125-3200</address>
<span>Phone: <a href="tel:+1-626-395-3405">(626)395-3405</a></span>
<span><a href="mailto:[email protected]">Email Us</a></span>
<a class="cl-hide" href="sitemap.xml">Site Map</a>
</footer>
</body>
</html>