小さな awk スクリプトに問題があるため、最新のログ ファイルを選択し、getline を使用してそれを読み取ろうとしています。問題は、最初にスクリプトに入力を送信しないと機能しないことです。
これは機能します
echo | myprog.awk
これはしません
myprog.awk
myprog.awk
BEGIN{
#find the newest file
command="ls -alrt | tail -1 | cut -c59-100"
command | getline logfile
close(command)
}
{
while((getline<logfile)>0){
#do the magic
print $0
}
}