<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Dec 31, 2015 at 4:06 AM, MR <span dir="ltr"><<a href="mailto:mrzenwiz@gmail.com" target="_blank">mrzenwiz@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote"><span class="">On Wed, Dec 30, 2015 at 11:03 AM, Normand Marion <span dir="ltr"><<a href="mailto:normand.marion@gmail.com" target="_blank">normand.marion@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr">2015-12-29 10:12 GMT-05:00 asad <span dir="ltr"><<a href="mailto:a.alii85@gmail.com" target="_blank">a.alii85@gmail.com</a>></span>:<br></div><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr">I'm using<br><br>    awk 'BEGIN {while((getline gf < "awk.script") > 0) {print gf}}' <br><br>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.<br><br>Suppose awk.script contains<br><br><br>    line 1<br>    line 2<br>    line 3 <------- until here<br>    line 4 <br><br>I have tried updating the original cmd with this<br><br>     awk 'BEGIN {while((getline gf < "awk.script") > 0) && f{print $gf;f=0};NR<=3{f=1}}'<br><br>the code is influenced from the examples give on link:-<br><a href="http://stackoverflow.com/questions/17908555/printing-with-sed-or-awk-a-line-following-a-matching-pattern" target="_blank">http://stackoverflow.com/questions/17908555/printing-with-sed-or-awk-a-line-following-a-matching-pattern</a><br><br>error i'm getting is<br><br>    awk: cmd. line:1: BEGIN {while((getline gf < "awk.script") > 0) f{print $gf;f=0};NR<=3{f=1}}<br>    awk: cmd. line:1:                                                ^ syntax error<br>    awk: cmd. line:1: BEGIN {while((getline gf < "awk.script") > 0) f{print $gf;f=0};NR<=3{f=1}}<br>    awk: cmd. line:1:<br><br>How can it be done? thanks<span><font color="#888888"><br></font></span></div><span><font color="#888888">
<br></font></span></blockquote></div></div></blockquote><div dir="ltr">awk '{ if ( NR <= 3 ) print $0 }' your_file<br></div><div class="gmail_extra"><br></div></span><div>You can also do this to save time in case the file is large:</div><div><br></div><div>awk '{print $0;} NR >= 3 { exit; }' your_file</div><div><br></div></div></div></div></blockquote><div>thanks but this only caters for single file not two?. <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div></div></div></div></div>
<br>--<br>
ubuntu-users mailing list<br>
<a href="mailto:ubuntu-users@lists.ubuntu.com">ubuntu-users@lists.ubuntu.com</a><br>
Modify settings or unsubscribe at: <a href="https://lists.ubuntu.com/mailman/listinfo/ubuntu-users" rel="noreferrer" target="_blank">https://lists.ubuntu.com/mailman/listinfo/ubuntu-users</a><br>
<br></blockquote></div><br></div></div>