AWK usage in shell script. Hp unix

时光毁灭记忆、已成空白 提交于 2020-01-14 05:41:50

问题


I'm unable to use the below command using shell script.

awk '{a[NR]=$0} $0~s {f=NR} END {for (i=f-B;i<=f+A;i++) print a[i]}' B=1 A=5 s="5S5SDF" testfile 

Looking for a string "5S5SDF" in testfile.

cat myscript

#!/bin/ksh

echo "The output is"

awk '{a[NR]=$0} $0~s {f=NR} END {for (i=f-B;i<=f+A;i++) print a[i]}' B=1 A=4 s=
 "5S5SDF" testfile

The system doesn't display anything, after i pause break i see error

myscript[5]: 77144447 Quit
myscript[6]: 5S5SDF:  not found

What am i missing?

来源:https://stackoverflow.com/questions/25930617/awk-usage-in-shell-script-hp-unix

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!