简体   繁体   English

如何在bash脚本中查找冒号并将其替换为冒号?

[英]How to find and replace forwardslashes with colons in bash script?

What I'm trying right now: 我现在正在尝试的是:

dir=$(pwd)
dir=${$dir//\//:}

But this isn't working for some reason. 但是由于某种原因,这是行不通的。

The whole point of this is to convert a bash path to an applescript path, without hardcoding the path in there. 这样做的全部目的是将bash路径转换为applescript路径,而无需在那里对路径进行硬编码。

I'm essentially trying to do the opposite of this: https://apple.stackexchange.com/questions/4938/how-to-change-applescript-path-to-a-terminal-style-path 我实质上是在尝试与此相反: https : //apple.stackexchange.com/questions/4938/how-to-change-applescript-path-to-a-terminal-style-path

您的语法略有偏离,请不要 ${}构造中的变量上使用$

dir=${dir//\//:}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM