• Uncategorized

About linux : how-to-change-charcter—with-in-bash-script-closed

Question Detail

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!

Question Answer

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

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.