基本上我需要创建一个传递参数的函数,我需要更新数字,例如参数是
version_2 并在函数之后将其更改为 version_3
只是增加一
在 java 中,我只会创建一个新字符串,然后将最后一个字符更新一个并附加,但不确定如何在 bash 中执行此操作。
updateVersion() {
version=$1
}
Run Code Online (Sandbox Code Playgroud)
前缀可以是任何东西,例如可以是 dog12 或 dog_12,并且总是有一个要更新的数字。
更新后分别是 dog13 或 dog_13。
我的 find 命令的结果产生以下结果
./alex20_0
./alex20_1
./alex20_2
./alex20_3
Run Code Online (Sandbox Code Playgroud)
我将此结果保存为变量。现在我真正需要的唯一部分是最后一部分是什么,或者基本上是最高数字或“最新版本”。
所以从上面的字符串中,我需要提取的只是./alex20_3并将其保存为变量。有没有办法只提取从 find 命令输出的最后一个目录?
我会执行最后第 n 个字符命令来提取它,因为它已经按顺序排列了,但是一旦我们到达版本./alex20_10等,它的字符数就不会相同。
I have an html file called index.html, and it has this div in there
<body>
<div id="rock"> <img src="rock.PNG" alt="rock" onclick="test()"> </div>
<div id="paper"> <img src="paper.PNG" alt="rock"></div>
<div id="scissors"> <img src="scissors.PNG" alt="rock"> </div>
Run Code Online (Sandbox Code Playgroud)
test is my function, and its within the same file and its written here
<script type="text/javascript">
function test(){
var elem = document.getElementById("rock");
var pos = 0;
var id = setInterval(frame, 10);
function frame() {
if (pos == 350) {
clearInterval(id);
} else {
pos++;
elem.style.top = pos …Run Code Online (Sandbox Code Playgroud)