<?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 Remove columns in file in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/remove-columns-in-file/m-p/4101923#M92610</link>
    <description>Hi.&lt;BR /&gt;Please, &lt;BR /&gt;I have a file which has some rows and this has  22 columns, separated by tab, however I want to create a new file or in the same one that I take off the head and alone it places 20 columns, of equal it forms separated by tab&lt;BR /&gt;&lt;BR /&gt;Their help with a script that allows me to make this.  &lt;BR /&gt;Thank you&lt;BR /&gt;&lt;BR /&gt;"Attachment deleted as it appeared to contain priveleged information"</description>
    <pubDate>Tue, 13 Nov 2007 16:42:27 GMT</pubDate>
    <dc:creator>Paola Guizado</dc:creator>
    <dc:date>2007-11-13T16:42:27Z</dc:date>
    <item>
      <title>Remove columns in file</title>
      <link>https://community.hpe.com/t5/operating-system-linux/remove-columns-in-file/m-p/4101923#M92610</link>
      <description>Hi.&lt;BR /&gt;Please, &lt;BR /&gt;I have a file which has some rows and this has  22 columns, separated by tab, however I want to create a new file or in the same one that I take off the head and alone it places 20 columns, of equal it forms separated by tab&lt;BR /&gt;&lt;BR /&gt;Their help with a script that allows me to make this.  &lt;BR /&gt;Thank you&lt;BR /&gt;&lt;BR /&gt;"Attachment deleted as it appeared to contain priveleged information"</description>
      <pubDate>Tue, 13 Nov 2007 16:42:27 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/remove-columns-in-file/m-p/4101923#M92610</guid>
      <dc:creator>Paola Guizado</dc:creator>
      <dc:date>2007-11-13T16:42:27Z</dc:date>
    </item>
    <item>
      <title>Re: Remove columns in file</title>
      <link>https://community.hpe.com/t5/operating-system-linux/remove-columns-in-file/m-p/4101924#M92611</link>
      <description>Hi Paola:&lt;BR /&gt;&lt;BR /&gt;# perl -nle 'next if $.==1;@a=split;print join "\t", @a[0..19] file&lt;BR /&gt;&lt;BR /&gt;This will skip the first line of 'file' and output twenty (20) columns of data from each row read using a tab (\t) as a column field seperator.  Perl counts zero-relative, hence the [0..19] slice.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Tue, 13 Nov 2007 17:56:29 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/remove-columns-in-file/m-p/4101924#M92611</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2007-11-13T17:56:29Z</dc:date>
    </item>
    <item>
      <title>Re: Remove columns in file</title>
      <link>https://community.hpe.com/t5/operating-system-linux/remove-columns-in-file/m-p/4101925#M92612</link>
      <description>&lt;P&gt;You can use awk. The character after -F and OFS= is a tab:&lt;BR /&gt;awk -F" " -v OFS=" " '&lt;BR /&gt;BEGIN { getline } # skip first&lt;BR /&gt;{&lt;BR /&gt;print $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20&lt;BR /&gt;} ' filename&lt;/P&gt;</description>
      <pubDate>Sun, 18 Sep 2011 19:47:24 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/remove-columns-in-file/m-p/4101925#M92612</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2011-09-18T19:47:24Z</dc:date>
    </item>
    <item>
      <title>Re: Remove columns in file</title>
      <link>https://community.hpe.com/t5/operating-system-linux/remove-columns-in-file/m-p/4101926#M92613</link>
      <description>Ok thanks.&lt;BR /&gt;This is:&lt;BR /&gt;awk -F"\t" -v OFS="\t" '&lt;BR /&gt;BEGIN { getline } # skip first&lt;BR /&gt;{&lt;BR /&gt;print $1, $2, $3, $4, $5, $6, $7, $8, $9, $10,&lt;BR /&gt;$11, $12, $13, $14, $15, $16, $17, $18, $19, $20&lt;BR /&gt;} ' casita.txt&lt;BR /&gt;</description>
      <pubDate>Wed, 14 Nov 2007 09:29:36 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/remove-columns-in-file/m-p/4101926#M92613</guid>
      <dc:creator>Paola Guizado</dc:creator>
      <dc:date>2007-11-14T09:29:36Z</dc:date>
    </item>
    <item>
      <title>Re: Remove columns in file</title>
      <link>https://community.hpe.com/t5/operating-system-linux/remove-columns-in-file/m-p/4101927#M92614</link>
      <description>Hi (again) Paola:&lt;BR /&gt;&lt;BR /&gt;The Perl solution splits the fields of your input file on "whitespace" which means that either spaces OR tab characters (or both) can delimit your input fields.  As you requested, the output field seperators are tab characters (\t).&lt;BR /&gt;&lt;BR /&gt;Of course, the Perl solution is quite short :-))&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Wed, 14 Nov 2007 09:43:55 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/remove-columns-in-file/m-p/4101927#M92614</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2007-11-14T09:43:55Z</dc:date>
    </item>
    <item>
      <title>Re: Remove columns in file</title>
      <link>https://community.hpe.com/t5/operating-system-linux/remove-columns-in-file/m-p/4101928#M92615</link>
      <description>Hi.&lt;BR /&gt;That I modify in script if I want to maintain the head??&lt;BR /&gt;Thanks.</description>
      <pubDate>Wed, 14 Nov 2007 17:50:53 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/remove-columns-in-file/m-p/4101928#M92615</guid>
      <dc:creator>Paola Guizado</dc:creator>
      <dc:date>2007-11-14T17:50:53Z</dc:date>
    </item>
    <item>
      <title>Re: Remove columns in file</title>
      <link>https://community.hpe.com/t5/operating-system-linux/remove-columns-in-file/m-p/4101929#M92616</link>
      <description>Yet another wat of doing the same thing:&lt;BR /&gt;&lt;BR /&gt;# awk -F'\t' 'NR&amp;gt;1 {for(i=1;i&amp;lt;=20;++i) printf(i&amp;lt;20?"%s\t":"%s\n",$i)}' ofile</description>
      <pubDate>Wed, 14 Nov 2007 18:26:57 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/remove-columns-in-file/m-p/4101929#M92616</guid>
      <dc:creator>Sandman!</dc:creator>
      <dc:date>2007-11-14T18:26:57Z</dc:date>
    </item>
    <item>
      <title>Re: Remove columns in file</title>
      <link>https://community.hpe.com/t5/operating-system-linux/remove-columns-in-file/m-p/4101930#M92617</link>
      <description>Hi (again);&lt;BR /&gt;&lt;BR /&gt;&amp;gt; That I modify in script if I want to maintain the head??&lt;BR /&gt;&lt;BR /&gt;This will retain the first line ($.==1) of your file in an unaltered state but produce output of twenty tab-seperated fields from the remaining lines:&lt;BR /&gt;&lt;BR /&gt;# perl -nle 'print if $.==1;@a=split;print join "\t", @a[0..19] file&lt;BR /&gt;&lt;BR /&gt;Now, if you want to update your 'file' "in-place" while creating a backup of the original file ('file.old'), do:&lt;BR /&gt;&lt;BR /&gt;# perl -ni.old -le 'print if $.==1;@a=split;print join "\t", @a[0..19] file&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;BR /&gt;</description>
      <pubDate>Wed, 14 Nov 2007 18:57:26 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/remove-columns-in-file/m-p/4101930#M92617</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2007-11-14T18:57:26Z</dc:date>
    </item>
    <item>
      <title>Re: Remove columns in file</title>
      <link>https://community.hpe.com/t5/operating-system-linux/remove-columns-in-file/m-p/4101931#M92618</link>
      <description>&amp;gt;That I modify in script if I want to maintain the head??&lt;BR /&gt;&lt;BR /&gt;For awk, if you don't want to truncate the extra columns:&lt;BR /&gt;BEGIN { getline; print $0 } # print first&lt;BR /&gt;...&lt;BR /&gt;If every column title is tab delimited and you want to delete the name, just remove that BEGIN and process the headings as normal data.&lt;BR /&gt;&lt;BR /&gt;&amp;gt;JRF: the Perl solution is quite short :-))&lt;BR /&gt;&amp;gt;Sandman:  Yet another way of doing the same thing:&lt;BR /&gt;&lt;BR /&gt;The reason I spelled everything out in awk is to allow future more complex changes and be more maintainable.&lt;BR /&gt;&lt;BR /&gt;If our answers were helpful please read the following about assigning points:&lt;BR /&gt;&lt;A href="http://forums1.itrc.hp.com/service/forums/helptips.do?#33" target="_blank"&gt;http://forums1.itrc.hp.com/service/forums/helptips.do?#33&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Also if no further questions you should close the thread.&lt;BR /&gt;</description>
      <pubDate>Wed, 14 Nov 2007 19:29:17 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/remove-columns-in-file/m-p/4101931#M92618</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2007-11-14T19:29:17Z</dc:date>
    </item>
    <item>
      <title>Re: Remove columns in file</title>
      <link>https://community.hpe.com/t5/operating-system-linux/remove-columns-in-file/m-p/4101932#M92619</link>
      <description>head -1 casita.txt | awk -F"\t" -v OFS="\t" '&lt;BR /&gt;BEGIN { getline } # skip first&lt;BR /&gt;{&lt;BR /&gt;print $1, $2, $3, $4, $5, $6, $7, $8, $9, $10,&lt;BR /&gt;$11, $12, $13, $14, $15, $16, $17, $18, $19, $20&lt;BR /&gt;} '&lt;BR /&gt;&lt;BR /&gt;intLine=`cat casota.txt | wc -l`&lt;BR /&gt;&lt;BR /&gt;tail -${intLine} | awk -F"\t" -v OFS="\t" '&lt;BR /&gt;BEGIN { getline } # skip first&lt;BR /&gt;{&lt;BR /&gt;print $1, $2, $3, $4, $5, $6, $7, $8, $9, $10,&lt;BR /&gt;$11, $12, $13, $14, $15, $16, $17, $18, $19, $20&lt;BR /&gt;} '&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;I have given the shell script, you can use it. Here I assume your file is casota.txt.&lt;BR /&gt;&lt;BR /&gt;Modify according to your requirement.&lt;BR /&gt;&lt;BR /&gt;Rgds&lt;BR /&gt;-NKG-</description>
      <pubDate>Thu, 29 Nov 2007 05:46:40 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/remove-columns-in-file/m-p/4101932#M92619</guid>
      <dc:creator>Nitin Kumar Gupta</dc:creator>
      <dc:date>2007-11-29T05:46:40Z</dc:date>
    </item>
  </channel>
</rss>

