我在学习代码测试时遇到了"土耳其测试"这个词.我真的不知道这意味着什么.
什么是土耳其测试?为什么这么称呼?
我正在编写一个脚本,它需要一个简单的短格式的bash版本号.
我知道bash --version
,但这会产生很长的输出:
GNU bash, version 4.2.10(1)-release (i686-pc-linux-gnu)
Copyright (C) 2011 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Run Code Online (Sandbox Code Playgroud)
这可以减少到我想要的位4.2.10
,通过这个:
bash --version | grep "bash" | cut -f 4 -d " " | cut -d "-" -f 1 | cut -d "(" -f 1
Run Code Online (Sandbox Code Playgroud)
然而,如果该消息由于某种原因而稍微改变,则感觉它容易破裂.
有没有更好的方法来做到这一点,这有什么更好的方法?