在bash一号线条件 [英] One line condition in bash
本文介绍了在bash一号线条件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有人问我,我当然HW写只用一条线,没有在bash的对比;。
我需要检查的变量'FNAME该字符串是否以字母'C'结束,如果是要打印匹配。有没有别的命令。我怎么能做到在同一行?
I'm asked in my course HW to write a comparison in bash using just one line and without ';'. I am required to check whether the string in the variable 'fname' ends with the letter 'C', and if so to print "Match". There is no else command. how can I do it in one line?
推荐答案
你知道的&放大器;&安培;
, ||
和&功放;在bash
命令终结
[[ "${fname:(-1)}" == "C" ]] && echo Match
这篇关于在bash一号线条件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文