开发者

Convert variable to lower string and concatenate

Why this is not working:

MDB="user_"+${PROJECT | tr '[:upper:]' '[:lower:]'}
开发者_高级运维

Please help. Thanks.


Are you familiar with chcase ?


What are you trying to do? Are you attempting to translate whatever ${PROJECT} is into lower case before setting MDB?

MDB="user_$(echo ${PROJECT} | tr [:upper:] [:lower:])"

The $(..) tells the shell to execute the command and replace the text with the standard of that command.


MDB="$(echo "user_$PROJECT" | tr '[:upper:]' '[:lower:]')"

(Note: the outer double-quotes aren't strictly necessary here, but there are a lot of places where leaving them out'll cause subtle bugs, so I tend to err on the side of overuse.)


MDB="user_${PROJECT}" | tr "[:upper:]" "[:lower:]"

in bash


Try this:

cat MDB="user_${PROJECT}| tr '[a-z]' '[A-Z]' > user_${PROJECT} // OR whatever you want to name your file.


You have a slight syntax error in your bash script. Modify it just slightly so that it looks like the following:

MDB="$(echo "user_$PROJECT" | tr '[:upper:]' '[:lower:]')" 

Good luck!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜