bash - 在 Ubuntu 中使用 bashrc 定义带循环的别名

标签 bash ubuntu environment-variables

使用别名很方便
但在这种情况下

alias ssh.1='ssh user@192.168.0.1'
alias ssh.2='ssh user@192.168.0.2'
alias ssh.3='ssh user@192.168.0.3'
我想通过 ssh 连接到范围 192.169.0.[0-100],
如何使用带循环的变量来设置它
或者我只是逐行定义它?

最佳答案

您可以使用循环

for i in {1..100}
do
   alias ssh.$i="ssh user@192.168.0.$i"
done

关于bash - 在 Ubuntu 中使用 bashrc 定义带循环的别名,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68388806/

相关文章:

linux - tmux:混淆行为与重定向和管道

linux - 在格式化的 bash 脚本中比较日期和日志

environment-variables - 如何在TCL中打印所有环境变量?

java - Intellij 支持启动配置中的变量吗?

Bash - 解析 bash 函数中的环境变量

qt - 在没有 openGL 的情况下使用 Qt

python - WebDriverException : Message: Service chromedriver unexpectedly exited. 状态代码为:127,在 Ubuntu 中使用 ChromeDriver 和 Selenium

mysql - ubuntu命令行上的SQL错误

node.js - 修改 $PATH 变量

bash - 如何发布带有需要转义字符的 curl 的 json 字符串?