简体   繁体   中英

how to change charcter - with / in bash script

In the bash script, suppose I have a string val my_str="model-id" , I want to replace character '-' with character '/' . How to do that?

I tried the following way, but it doesn't work:

echo "$my_tsr" | tr - /

Can some one tell me how to solve it? Thank you!

my_str="model-id"
new_str=${my_str//-//}
echo "$new_str"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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