linux shell 之常用的内置变量

内部变量BASH:

echo $BASH
/bin/bash
内部变量BASH_VERSINFO

vi bashver.sh
#!/bin/bash
for n in 0 1 2 3 4 5
do
echo "BASH_VERSINFO[$n]=${BASH_VERSINFO[$n]}"
done

./bashver.sh
BASH_VERSINFO[0]=4
BASH_VERSINFO[1]=4
BASH_VERSINFO[2]=20
BASH_VERSINFO[3]=1
BASH_VERSINFO[4]=release
BASH_VERSINFO[5]=x86_64-pc-linux-gnu

内部变量BASH_VERSION
echo $BASH_VERSION
4.4.20(1)-release

内部变量DIRSTACK
echo $DIRSTACK
~/test_program

内部变量GLOBIGNORE
表示冒号分隔的模式列表,表示通配时忽略的集合名字

ls f*
facebook.txt for_exam10.sh for_exam3.sh for_exam6.sh for_exam9.sh
father.sh for_exam1.sh for_exam4.sh for_exam8.sh

GLOBIGNORE="fa*"
ls f*
for_exam10.sh for_exam3.sh for_exam6.sh for_exam9.sh
for_exam1.sh for_exam4.sh for_exam8.sh

内置变量GROUP
echo $GROUPS
1000

cat /etc/group
root:x:0:
daemon:x:1:
bin:x:2:
sys:x:3:
adm:x:4:syslog,daheng
tty:x:5:
disk:x:6:
lp:x:7:
mail:x:8:
news:x:9:
uucp:x:10:
man:x:12:
proxy:x:13:
kmem:x:15:
dialout:x:20:
fax:x:21:
voice:x:22:
cdrom:x:24:daheng
floppy:x:25:
tape:x:26:
sudo:x:27:daheng
audio:x:29:pulse
dip:x:30:daheng
www-data:x:33:
backup:x:34:
operator:x:37:
list:x:38:
irc:x:39:
src:x:40:
daheng:x:1000:
sambashare:x:126:daheng
rdma:x:127:
pulse:x:123:
pulse-access:x:124:

echo $HOSTNAME
ubuntu

echo $HOSTTYPE
x86_64
echo $MACHTYPE
x86_64-pc-linux-gnu

echo $OSTYPE
linux-gnu

linux shell 之常用的内置变量

上一篇:「Linux」- 使用WPA Supplicant连接无线热点 @20210329


下一篇:「Linux」- 从MAC地址中获取IP地址 @20210329