Implement tail with awk

后端 未结 4 1553
失恋的感觉
失恋的感觉 2021-01-19 16:44

Alright so here i am struggling with this awk code wich should emulate the tail command

num=$1;
{
    vect[NR]=$0;

}
END{
    for(i=NR-num;i<=NR;i++)
            


        
4条回答
  •  盖世英雄少女心
    2021-01-19 17:33

    You need to add -v num=10 to the awk commandline to set the value of num. And start at NR-num+1 in your final loop, otherwise you'll end up with num+1 lines of output.

提交回复
热议问题