-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathposition.html
92 lines (90 loc) · 2.44 KB
/
position.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
<!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="../../index.html">README</a>
</li>
<li>
<a href="../../license.html">LICENSE</a>
</li>
<li>
<a href="../../install.html">INSTALL</a>
</li>
<li>
<a href="../../how-to/">How To</a>
</li>
<li>
<a href="../user-manual.html">User Manual</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="string-position-target-string">
string position TARGET [STRING]
</h1>
<p>
This command will return the position (where zero is the first position)
of TARGET in STRING. If the TARGET is not found a negative 1 will be
returned.
</p>
<h2 id="typical-command-line">
Typical command line
</h2>
<p>
NOTE: we’ll use the option <code>-nl</code> to append a new line to the
output and make it easier to read.
</p>
<pre class="shell"><code> string -nl position "friend" "The people were friendly"</code></pre>
<p>
Would return <code>16</code>
</p>
<pre class="shell"><code> string position "tomato" "The people were friendly"</code></pre>
<p>
Would return <code>-1</code>
</p>
<h2 id="piping-content">
Piping content
</h2>
<p>
NOTE: To read content from standard input we use the <code>-i -</code>
option.
</p>
<pre class="shell"><code> echo "The people were friendly" | string -nl -i - position "friend"</code></pre>
<p>
Would return <code>16</code>
</p>
<pre class="shell"><code> echo "The people were friendly" | string -nl -i - position "apple"</code></pre>
<p>
Would return <code>-1</code>
</p>
</section>
<footer>
<span><h1><A href="http://caltech.edu">Caltech</a></h1></span>
<span>© 2021 <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>