<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: head / tail function in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/head-tail-function/m-p/2943922#M4113</link>
    <description>suppose the numbers are as follows in a.txt -&lt;BR /&gt;&lt;BR /&gt;1&lt;BR /&gt;2&lt;BR /&gt;3&lt;BR /&gt;4&lt;BR /&gt;5&lt;BR /&gt;.&lt;BR /&gt;.&lt;BR /&gt;.&lt;BR /&gt;10&lt;BR /&gt;&lt;BR /&gt;#!/bin/bash&lt;BR /&gt;&lt;BR /&gt;# expects number of lines to be removed from head and tail as argument&lt;BR /&gt;&lt;BR /&gt;nlines=`wc -l a.txt | awk '{print $1}'`&lt;BR /&gt;&lt;BR /&gt;nlines=`expr $nlines - $1`&lt;BR /&gt;hlines=`expr $nlines - $1`&lt;BR /&gt;&lt;BR /&gt;tail -$nlines a.txt | head -$hlines&lt;BR /&gt;&lt;BR /&gt;# EOF&lt;BR /&gt;&lt;BR /&gt;should work.&lt;BR /&gt;&lt;BR /&gt;- ramd.&lt;BR /&gt;&lt;BR /&gt;</description>
    <pubDate>Fri, 04 Apr 2003 11:37:42 GMT</pubDate>
    <dc:creator>Ramkumar Devanathan</dc:creator>
    <dc:date>2003-04-04T11:37:42Z</dc:date>
    <item>
      <title>head / tail function</title>
      <link>https://community.hpe.com/t5/operating-system-linux/head-tail-function/m-p/2943921#M4112</link>
      <description>people,&lt;BR /&gt;&lt;BR /&gt;if I have a file thus :&lt;BR /&gt;&lt;BR /&gt;1&lt;BR /&gt;2&lt;BR /&gt;3&lt;BR /&gt;4&lt;BR /&gt;5&lt;BR /&gt;&lt;BR /&gt;and I wanted to get a section, or number of lines from the middle (using two line numbers) i.e. :&lt;BR /&gt;&lt;BR /&gt;2&lt;BR /&gt;3&lt;BR /&gt;4&lt;BR /&gt;&lt;BR /&gt;how would I do this (could I use head or tail?)&lt;BR /&gt;&lt;BR /&gt;many thanks&lt;BR /&gt;John</description>
      <pubDate>Fri, 04 Apr 2003 11:18:08 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/head-tail-function/m-p/2943921#M4112</guid>
      <dc:creator>u856100</dc:creator>
      <dc:date>2003-04-04T11:18:08Z</dc:date>
    </item>
    <item>
      <title>Re: head / tail function</title>
      <link>https://community.hpe.com/t5/operating-system-linux/head-tail-function/m-p/2943922#M4113</link>
      <description>suppose the numbers are as follows in a.txt -&lt;BR /&gt;&lt;BR /&gt;1&lt;BR /&gt;2&lt;BR /&gt;3&lt;BR /&gt;4&lt;BR /&gt;5&lt;BR /&gt;.&lt;BR /&gt;.&lt;BR /&gt;.&lt;BR /&gt;10&lt;BR /&gt;&lt;BR /&gt;#!/bin/bash&lt;BR /&gt;&lt;BR /&gt;# expects number of lines to be removed from head and tail as argument&lt;BR /&gt;&lt;BR /&gt;nlines=`wc -l a.txt | awk '{print $1}'`&lt;BR /&gt;&lt;BR /&gt;nlines=`expr $nlines - $1`&lt;BR /&gt;hlines=`expr $nlines - $1`&lt;BR /&gt;&lt;BR /&gt;tail -$nlines a.txt | head -$hlines&lt;BR /&gt;&lt;BR /&gt;# EOF&lt;BR /&gt;&lt;BR /&gt;should work.&lt;BR /&gt;&lt;BR /&gt;- ramd.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 04 Apr 2003 11:37:42 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/head-tail-function/m-p/2943922#M4113</guid>
      <dc:creator>Ramkumar Devanathan</dc:creator>
      <dc:date>2003-04-04T11:37:42Z</dc:date>
    </item>
    <item>
      <title>Re: head / tail function</title>
      <link>https://community.hpe.com/t5/operating-system-linux/head-tail-function/m-p/2943923#M4114</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;This is one way to do it using head and tail:&lt;BR /&gt;&lt;BR /&gt;head -4 file | tail +2&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;The problem with head and tail is that they have a limited buffer space to work with, so they work fine with smaller files but not with large files.  Probably Perl is a better choice to work with most any size file.  You can do it like this with Perl:&lt;BR /&gt;&lt;BR /&gt;perl -ne '2..4 and print' file&lt;BR /&gt;&lt;BR /&gt;JP&lt;BR /&gt;</description>
      <pubDate>Fri, 04 Apr 2003 11:43:10 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/head-tail-function/m-p/2943923#M4114</guid>
      <dc:creator>John Poff</dc:creator>
      <dc:date>2003-04-04T11:43:10Z</dc:date>
    </item>
    <item>
      <title>Re: head / tail function</title>
      <link>https://community.hpe.com/t5/operating-system-linux/head-tail-function/m-p/2943924#M4115</link>
      <description>Sorry I misunderstood as a script to remove n lines from beginning and end of file.&lt;BR /&gt;&lt;BR /&gt;Probably perl would be a better option as pointed out.&lt;BR /&gt;&lt;BR /&gt;- ramd.</description>
      <pubDate>Fri, 04 Apr 2003 12:05:11 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/head-tail-function/m-p/2943924#M4115</guid>
      <dc:creator>Ramkumar Devanathan</dc:creator>
      <dc:date>2003-04-04T12:05:11Z</dc:date>
    </item>
    <item>
      <title>Re: head / tail function</title>
      <link>https://community.hpe.com/t5/operating-system-linux/head-tail-function/m-p/2943925#M4116</link>
      <description>Or even sed :&lt;BR /&gt;&lt;BR /&gt;sed -ne '2,5p' filename&lt;BR /&gt;&lt;BR /&gt;HTH,&lt;BR /&gt;G.</description>
      <pubDate>Fri, 04 Apr 2003 12:16:28 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/head-tail-function/m-p/2943925#M4116</guid>
      <dc:creator>Goran Koruga</dc:creator>
      <dc:date>2003-04-04T12:16:28Z</dc:date>
    </item>
  </channel>
</rss>

