sed 和 awk的使用

1. 固定宽度的摘录

lili@lili-debian:~/workspace/temp$ export AWKPATH=/home/lili/workspace/github-workspace/mycode/awk
lili@lili-debian:~/workspace/temp$ awk -f width-sep.awk temp.txt
456
lili@lili-debian:~/workspace/temp$ cat /home/lili/workspace/github-workspace/mycode/awk/width-sep.awk
BEGIN{
    FIELDWIDTHS="1 2 3 4"
}
{
    print $3
}


2. 从标准输入读入:

lili@lili-debian:~/workspace/temp$ awk 'BEGIN { getline number < "-" ;  if ( number ~ /[0-9]+/ ) { print "good" ; } else { print "bad";}}'

你可能感兴趣的:(linux相关的技术)