标签:用户 bsp 三种方式 echo ber passwd sys str pre
(1)getline从交互式的用户输入中\c中获取内容;
# awk ‘BEGIN {system("echo \"Input your name:\"");getline d;print "\nYour name is",d"!\n"}‘ Input your name: berry Your name is berry! # awk ‘BEGIN {system(" echo \"Input your name:\\c\" ");getline d;print "\nYour name is",d"!\n"}‘ Input your name:berry Your name is berry!
(2)getline从文件中获取内容;
# awk -F":" ‘BEGIN{while(getline < "/etc/passwd" >0){if($1~"sy"){print $1}}}‘
sys
sync
syslog
(3)从命令输出中获取;
# awk ‘BEGIN{"date" | getline d; print d}‘
Sun Jan 1 22:37:50 CST 2017
标签:用户 bsp 三种方式 echo ber passwd sys str pre
原文地址:http://www.cnblogs.com/Berryxiong/p/6241707.html