step1:
bash --version
result:
root@CN_PENGS01:/home/peng# bash --version
GNU bash, version 4.4.12(1)-release (x86_64-pc-linux-gnu)
Copyright (C) 2016 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.
step 2 , 把bash --version的输出 取第一行:
bash --version | head -n 1
result:
root@CN_PENGS01:/home/peng# bash --version | head -n 1
GNU bash, version 4.4.12(1)-release (x86_64-pc-linux-gnu)
step3,以空格为分隔符(delimiter),取第2到第4的field:
bash --version | head -n 1 | cut -d " " -f2-4
root@CN_PENGS01:/home/peng# bash --version | head -n 1 | cut -d " " -f2-4
bash, version 4.4.12(1)-release