1 如何把Bash Shell 变量传给awk
var="test"
awk 'BEGIN{print "'$var'"}'
$var="this is a test";export $var
awk 'BEGIN{print ENVIRON["var"]}'
$var="this is a test"
awk -vnvar="$var" '{print nvar}'
2.把awk的变量传递给Bash Shell
var1="test"
var2="along"
eval $(awk 'BEGIN{print "var1=along;var2=test"}')
echo "var1:"$var1
echo "var2:"$var2
把hello.c的内容按照宽度为1个字节(w1),按照无符号整型数(-t u1)打印,并移除第一行行号(An),不省略重复值(v)
od -w1 -t u1 -v -An hello.c
打印全部内容
awk ‘{print $0}’ hello.c
打印第一列内容
awk '{print $1}' hello.c
做checksum
od -w1 -t u1 -v -An hello.c | awk '{a+=$1}END{printf("0x%02X",a)}'
awk 正则表达式
http://www.cnblogs.com/chengmo/archive/2010/10/11/1847772.html
Bash shell 语法入门
http://www.blogjava.net/terry6394/archive/2007/01/13/93552.html
打印Checksum
sum hello.c
cksum hello.c
md5sum hello.c
linux 内核下载和coreutils
阅读(1290) | 评论(0) | 转发(0) |