首页 > 其他 > 详细

Awk Command Daily Work Summary

时间:2019-03-01 15:24:01      阅读:158      评论:0      收藏:0      [点我收藏+]

This article used to walk you through some commonly awk usages , based on a real life scenario.

################################################################
# ? Date ? ? ? ? ? Description
# ? 02/28/2019 ? ? print last column
# ? 02/26/2019 ? ? awk remote execution
#
################################################################

02/26/2019

When use awk in script, may suffer shell unexpected expanding:

ssh -o StrictHostKeyChecking=no sshrm1 "ifconfig eth0 | grep \"inet\" | awk '{print $2}'"

Above will not get right data, instead preceding \ before $

ssh -o StrictHostKeyChecking=no sshrm1 "ifconfig eth0 | grep \"inet\" | awk '{print \$2}'"

Another method is awk the return value from ssh rather than wrap it in ssh command.

02/28/2019

Print last column separated by space

awk '{print $NF}'

Awk Command Daily Work Summary

原文:https://www.cnblogs.com/chengdol/p/10456357.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!