shell - 用户指定的变量作为 shell 脚本循环中的计数器
问题描述
我想使用用户定义的计数器变量来操纵循环行为。我尝试将变量作为参数传递,并尝试在脚本本身中对它们进行硬编码,但没有任何效果。
#!/bin/bash
start_hour=0 #can be passed as argument ($1)
end_hour=24 #can be passed as argument ($2)
for i in {$((end_hour))..$((start_hour))}
do
echo $i
done
输出{24..0}
解决方案
推荐阅读
- android - Android:模拟滚动事件到底层屏幕
- javascript - 在 Windows 10 音量控制覆盖中显示视频元数据
- c# - SQL Query to LINQ(使用带有两个键的连接)
- mongodb - Vue.js 不能使用 v-model
- javascript - 重新绑定 onclick, on* 事件监听器进行调试
- java - Java中的LinkedList:为什么它直接从扩展类间接实现List
- android - Android:是否可以将任何语言创建的任何库添加到 Android 项目中?
- selenium - 无限循环中的视频自动播放
- java - 在我的 Java 游戏中实现主菜单时使用 createBufferStrategy(int) 生成错误
- android - 我创建了水平卡片,但它们没有显示在我的片段中?