bash - 波浪号的 Shell 扩展 ~ 在 bash shell 脚本中不起作用
问题描述
这是我的shell脚本
#!/bin/bash
d="${HOME}/image-dir"
# Expanding to /Users/napoleon/image-dir
d1="~/image-dir"
# Expands to ~/image-dir
also in the command line
echo "~" # output is ~
echo ~ # output is "/Users/napoleon"
有人可以解释这背后的原因吗?是否按照手册工作
这个问题的目的是了解为什么波浪号不能在双引号“~”内工作。
解决方案
推荐阅读
- mysql - 我在选择这个更新时做错了什么
- c# - AuthenticationHandler 每次都调用,甚至不需要 Controller 授权
- android - android studio 中 android 应用程序的 ip 摄像头视图
- java - 为什么不让返回类型 String 允许我在函数中返回字符串
- javascript - 在反应中管理嵌套组件中的状态
- java - Proguard for java混淆,从windows迁移到mac,找不到classes.jar
- reactjs - 反应路由器 - 重定向除一个以外的所有路由
- java - 在 Spinner itemSelected 上重新加载数据
- javascript - Uncaught (in promise) ReferenceError: isBlack is not defined
- android - 什么是通过键对 SparseArray 进行排序的有效方法?