(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

 

相关文章:

  • 2022-12-23
  • 2021-10-08
  • 2022-12-23
  • 2021-12-19
  • 2021-11-27
  • 2021-05-05
  • 2021-04-24
  • 2021-08-30
猜你喜欢
  • 2021-06-15
  • 2022-12-23
  • 2021-06-07
  • 2022-02-13
  • 2022-12-23
相关资源
相似解决方案