Linux shell command cut All In One
cut 截取指定符号等号后面的字符串
cut 截取等号后面的字符串
# 获取 env
$ env
# 获取登录当前用户信息
$ env | grep USER
$ env | grep USER | cut -d "=" -f 2
# 获取登录当前用户信息
$ whomai
$ echo $USER
demos
#!/usr/bin/env bash
# coding: utf8
bug='throttled=0x50005'
state=$(vcgencmd get_throttled)
# echo $state
# 没有空格 bug ❌
# if [$state == $bug]
# 有空格 OK ✅
# if [ $state == $bug ]
# 有空格 OK ✅
if [ $state == 'throttled=0x50005' ]
then
echo "❌ Error"
else
echo "✅ OK"
fi
WIFI=$(ifconfig | grep "192.168")
echo $WIFI