问题
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