cat grep awk sed用法

我也问一下,这样的正则表达式如何匹配等号两边没有空格或多个空格的情况?
比如我希望
echo "database=test "
echo "database =    test "
echo "database    =test  "
得到的都是 "test", test前后的空格也给去了


楼住对linux的基础还不是很熟悉,看看相关的教程
在赋值的时候等号于前面的变量不能有空格
当然可以做到
1)去掉所有的空格 sed 's/[ \t]//g'
2)去掉"datebase=" awk -F = '{print $2}'
3)结合起来 echo "database = test " | sed 's/[ \t]//g'| awk -F = '{print $2}'

$cmd =  "ifconfig eth0 | grep HWaddr|sed 's/[ \t]//g'";//调用top命令和grep命令
$macinfo = exec($cmd,$output);


$cmd =  "cat /proc/cpuinfo |grep Processor|sed 's/[ \t]//g'";//调用top命令和grep命令
$cpuinfo = exec($cmd,$output);

echo "cpuinfo=".$cpuinfo."<br/>";
echo "macinfo=".$macinfo."<br/>";

#my $cmd =  "ifconfig eth0 | grep HWaddr | awk '{print $5}'";#grep find line with HWaddr#awk find the 5th word of line
$cmd =  "ifconfig eth0 | grep HWaddr";
my $macinfo = readpipe($cmd);

print "mac========".$macinfo."\n";

#$cmd =  "cat /proc/cpuinfo |grep Processor| awk '{print $0}'";#grep find line with Processor#awk find line's all words

你可能感兴趣的:(grep)