awk getline to display first three lines in file
asad
a.alii85 at gmail.com
Tue Dec 29 15:12:12 UTC 2015
I'm using
awk 'BEGIN {while((getline gf < "awk.script") > 0) {print gf}}'
to read me first 3 three lines of the pattern. I can do with head -3 . But
I don't want to since, I have to switch lines between two files.
Suppose awk.script contains
line 1
line 2
line 3 <------- until here
line 4
I have tried updating the original cmd with this
awk 'BEGIN {while((getline gf < "awk.script") > 0) && f{print
$gf;f=0};NR<=3{f=1}}'
the code is influenced from the examples give on link:-
http://stackoverflow.com/questions/17908555/printing-with-sed-or-awk-a-line-following-a-matching-pattern
error i'm getting is
awk: cmd. line:1: BEGIN {while((getline gf < "awk.script") > 0) f{print
$gf;f=0};NR<=3{f=1}}
awk: cmd. line:1: ^
syntax error
awk: cmd. line:1: BEGIN {while((getline gf < "awk.script") > 0) f{print
$gf;f=0};NR<=3{f=1}}
awk: cmd. line:1:
How can it be done? thanks
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ubuntu.com/archives/ubuntu-users/attachments/20151229/4fc2d925/attachment.html>
More information about the ubuntu-users
mailing list