<?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: Shell script use to combine several files into one files in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-use-to-combine-several-files-into-one-files/m-p/2881117#M100930</link>
    <description>Here is a perl script that takes in account to NOT process the XXX00000 file as part of the input. It also has the benefit of not having to call external processes to copy each file.&lt;BR /&gt;&lt;BR /&gt;HTH&lt;BR /&gt;&lt;BR /&gt;-- Rod Hills&lt;BR /&gt;&lt;BR /&gt;open(LIS,"ls -1|");&lt;BR /&gt;$prv=""&lt;BR /&gt;while(&lt;LIS&gt;) {&lt;BR /&gt; chomp;&lt;BR /&gt; $fil=$_;&lt;BR /&gt; next if substr($fil,3,5) eq "00000" ;# ignore result file&lt;BR /&gt; $cur=substr($fil,0,3);&lt;BR /&gt; if ($prv ne $cur) {&lt;BR /&gt;  close OUT if $prv;&lt;BR /&gt;  open(OUT,"&amp;gt;${cur}00000");&lt;BR /&gt;  $prv=$cur;&lt;BR /&gt; }&lt;BR /&gt; open(INP,"&amp;lt;$fil");&lt;BR /&gt; while(&lt;INP&gt;) { print OUT $_; }&lt;BR /&gt; close INP;&lt;BR /&gt;}&lt;/INP&gt;&lt;/LIS&gt;</description>
    <pubDate>Tue, 14 Jan 2003 17:22:00 GMT</pubDate>
    <dc:creator>Rodney Hills</dc:creator>
    <dc:date>2003-01-14T17:22:00Z</dc:date>
    <item>
      <title>Shell script use to combine several files into one files</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-use-to-combine-several-files-into-one-files/m-p/2881102#M100915</link>
      <description>Dear professionals,&lt;BR /&gt;&lt;BR /&gt;I want to combine serveral text files into one textfiles. e.g.&lt;BR /&gt;&lt;BR /&gt;Severals Files in a directory:&lt;BR /&gt;AAA00001&lt;BR /&gt;AAA00002&lt;BR /&gt;AAA00003&lt;BR /&gt;AAA00004&lt;BR /&gt;BDD00001&lt;BR /&gt;BDD00002&lt;BR /&gt;BDD00003&lt;BR /&gt;BDD00004&lt;BR /&gt;BDD00005&lt;BR /&gt;.....&lt;BR /&gt;...&lt;BR /&gt;..&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;These files will be combined into:&lt;BR /&gt;AAA00000&lt;BR /&gt;BDD00000&lt;BR /&gt;....&lt;BR /&gt;..&lt;BR /&gt;.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Where the content of AAA00000 equal to the combination of AAA00001, AAA00002, AAA00003, AAA00004.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Pls advise&lt;BR /&gt;&lt;BR /&gt;Thanks a lot.</description>
      <pubDate>Tue, 14 Jan 2003 08:10:18 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-use-to-combine-several-files-into-one-files/m-p/2881102#M100915</guid>
      <dc:creator>wfalai</dc:creator>
      <dc:date>2003-01-14T08:10:18Z</dc:date>
    </item>
    <item>
      <title>Re: Shell script use to combine several files into one files</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-use-to-combine-several-files-into-one-files/m-p/2881103#M100916</link>
      <description>ls|cut -c-3|&lt;BR /&gt;while read fname&lt;BR /&gt;do&lt;BR /&gt;  cat ${fname}* &amp;gt;${fname}00000&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;something like that</description>
      <pubDate>Tue, 14 Jan 2003 08:31:25 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-use-to-combine-several-files-into-one-files/m-p/2881103#M100916</guid>
      <dc:creator>Systeemingenieurs Infoc</dc:creator>
      <dc:date>2003-01-14T08:31:25Z</dc:date>
    </item>
    <item>
      <title>Re: Shell script use to combine several files into one files</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-use-to-combine-several-files-into-one-files/m-p/2881104#M100917</link>
      <description>should've been : ls |cut -c-3|sort -u|...</description>
      <pubDate>Tue, 14 Jan 2003 08:35:43 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-use-to-combine-several-files-into-one-files/m-p/2881104#M100917</guid>
      <dc:creator>Systeemingenieurs Infoc</dc:creator>
      <dc:date>2003-01-14T08:35:43Z</dc:date>
    </item>
    <item>
      <title>Re: Shell script use to combine several files into one files</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-use-to-combine-several-files-into-one-files/m-p/2881105#M100918</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;If I need to count back from the last position, say, 00001 and do a cut there.&lt;BR /&gt;&lt;BR /&gt;The remain text become AAA .&lt;BR /&gt;&lt;BR /&gt;How can I do .?&lt;BR /&gt;&lt;BR /&gt;Thanks a lot</description>
      <pubDate>Tue, 14 Jan 2003 09:09:34 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-use-to-combine-several-files-into-one-files/m-p/2881105#M100918</guid>
      <dc:creator>wfalai</dc:creator>
      <dc:date>2003-01-14T09:09:34Z</dc:date>
    </item>
    <item>
      <title>Re: Shell script use to combine several files into one files</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-use-to-combine-several-files-into-one-files/m-p/2881106#M100919</link>
      <description>Hi,&lt;BR /&gt;Try this:&lt;BR /&gt;for i in $(ls | cut -c1-3)&lt;BR /&gt;do&lt;BR /&gt;cat ${i}* &amp;gt;&amp;gt; ${i}00000&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;&lt;BR /&gt;Justo.</description>
      <pubDate>Tue, 14 Jan 2003 11:00:33 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-use-to-combine-several-files-into-one-files/m-p/2881106#M100919</guid>
      <dc:creator>Justo Exposito</dc:creator>
      <dc:date>2003-01-14T11:00:33Z</dc:date>
    </item>
    <item>
      <title>Re: Shell script use to combine several files into one files</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-use-to-combine-several-files-into-one-files/m-p/2881107#M100920</link>
      <description>Hi, &lt;BR /&gt;Sorry one correction: &lt;BR /&gt;for i in $(ls | cut -c1-3 | sort -u) &lt;BR /&gt;do &lt;BR /&gt;cat ${i}* &amp;gt;&amp;gt; ${i}00000 &lt;BR /&gt;done &lt;BR /&gt;&lt;BR /&gt;Regards, &lt;BR /&gt;&lt;BR /&gt;Justo.</description>
      <pubDate>Tue, 14 Jan 2003 11:13:49 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-use-to-combine-several-files-into-one-files/m-p/2881107#M100920</guid>
      <dc:creator>Justo Exposito</dc:creator>
      <dc:date>2003-01-14T11:13:49Z</dc:date>
    </item>
    <item>
      <title>Re: Shell script use to combine several files into one files</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-use-to-combine-several-files-into-one-files/m-p/2881108#M100921</link>
      <description>Thanks all..&lt;BR /&gt;&lt;BR /&gt;I should say that:&lt;BR /&gt;&lt;BR /&gt;"AAA" is the prefix of the filename. However, it is a randomly prefix pattern. So, say, it may be Dedss00001, Dedss00002.....etc., KKKAA00001, KKKAA00002...etc...&lt;BR /&gt;&lt;BR /&gt;Because many many files with different length there and I may not be possible to use " cut -c1-3 " apply to all of the files. So, how can I do so that the script can find how long of the prefix ? &lt;BR /&gt;&lt;BR /&gt;that is, cut -cx-y , where y is the last position of the filename and x is the 6th counting from the last position y.&lt;BR /&gt;&lt;BR /&gt;Thanks ...</description>
      <pubDate>Tue, 14 Jan 2003 15:58:46 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-use-to-combine-several-files-into-one-files/m-p/2881108#M100921</guid>
      <dc:creator>wfalai</dc:creator>
      <dc:date>2003-01-14T15:58:46Z</dc:date>
    </item>
    <item>
      <title>Re: Shell script use to combine several files into one files</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-use-to-combine-several-files-into-one-files/m-p/2881109#M100922</link>
      <description>something like ?&lt;BR /&gt;&lt;BR /&gt;ls -1 *[0-9][0-9][0-9][0-9][0-9][0-9] | awk '  { print  " cat" ,substr($1,1,length($1-6)) "[0-9][0-9][0-9][0-9][0-9][0-9] &amp;gt; " substr($1,1,length($1-6)) "0" }'&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 14 Jan 2003 16:13:29 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-use-to-combine-several-files-into-one-files/m-p/2881109#M100922</guid>
      <dc:creator>Carlos Fernandez Riera</dc:creator>
      <dc:date>2003-01-14T16:13:29Z</dc:date>
    </item>
    <item>
      <title>Re: Shell script use to combine several files into one files</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-use-to-combine-several-files-into-one-files/m-p/2881110#M100923</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;This is the solution if the last part is always six characters:&lt;BR /&gt;&lt;BR /&gt;for i in $(ls | sed 's/......$//' | sort -u) &lt;BR /&gt;do &lt;BR /&gt;cat ${i}* &amp;gt;&amp;gt; ${i}00000 &lt;BR /&gt;done &lt;BR /&gt;&lt;BR /&gt;Regards, &lt;BR /&gt;&lt;BR /&gt;Justo.</description>
      <pubDate>Tue, 14 Jan 2003 16:17:17 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-use-to-combine-several-files-into-one-files/m-p/2881110#M100923</guid>
      <dc:creator>Justo Exposito</dc:creator>
      <dc:date>2003-01-14T16:17:17Z</dc:date>
    </item>
    <item>
      <title>Re: Shell script use to combine several files into one files</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-use-to-combine-several-files-into-one-files/m-p/2881111#M100924</link>
      <description>&lt;BR /&gt;ls -1 *[0-9][0-9][0-9][0-9][0-9][0-9] | awk ' { print " cat" ,substr($1,1,length($1-6)) "[0-9][0-9][0-9][0-9][0-9][0-9] &amp;gt; " substr($1,1,length($1-6)) "0" }' &lt;BR /&gt;| sort -u &amp;gt; file_command&lt;BR /&gt;&lt;BR /&gt;sh file_command&lt;BR /&gt;</description>
      <pubDate>Tue, 14 Jan 2003 16:20:47 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-use-to-combine-several-files-into-one-files/m-p/2881111#M100924</guid>
      <dc:creator>Carlos Fernandez Riera</dc:creator>
      <dc:date>2003-01-14T16:20:47Z</dc:date>
    </item>
    <item>
      <title>Re: Shell script use to combine several files into one files</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-use-to-combine-several-files-into-one-files/m-p/2881112#M100925</link>
      <description>Hi:&lt;BR /&gt;&lt;BR /&gt;Given a filename you can use the shell's parameter substitution to get the basename and the length of that token.&lt;BR /&gt;&lt;BR /&gt;Given:&lt;BR /&gt;&lt;BR /&gt;# NAME=/var/tmp/filename&lt;BR /&gt;&lt;BR /&gt;# BN=${F##*/}&lt;BR /&gt;# echo $BN&lt;BR /&gt;#...returns "filename" or the 'basename'&lt;BR /&gt;&lt;BR /&gt;# L=${#BN}&lt;BR /&gt;# echo $L    &lt;BR /&gt;#...returns the length or here, eight (8)...&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...  &lt;BR /&gt;&lt;BR /&gt;L=${#F} will</description>
      <pubDate>Tue, 14 Jan 2003 16:22:38 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-use-to-combine-several-files-into-one-files/m-p/2881112#M100925</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2003-01-14T16:22:38Z</dc:date>
    </item>
    <item>
      <title>Re: Shell script use to combine several files into one files</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-use-to-combine-several-files-into-one-files/m-p/2881113#M100926</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;Fix your OLD suffix (one of the current files ie 000001) and NEW suffix (ie 000000) and try this one :&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;OLDSUF=001&lt;BR /&gt;NEWSUF=000&lt;BR /&gt;for var in *$OLDSUF&lt;BR /&gt;do&lt;BR /&gt;  PREF=$(echo $var | sed 's/'$OLDSUF'$//')&lt;BR /&gt;  cat ${PREF}* &amp;gt; ${PREF}${NEWSUF}&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;Regards</description>
      <pubDate>Tue, 14 Jan 2003 16:42:46 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-use-to-combine-several-files-into-one-files/m-p/2881113#M100926</guid>
      <dc:creator>Jean-Louis Phelix</dc:creator>
      <dc:date>2003-01-14T16:42:46Z</dc:date>
    </item>
    <item>
      <title>Re: Shell script use to combine several files into one files</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-use-to-combine-several-files-into-one-files/m-p/2881114#M100927</link>
      <description># perl -e'local$/;for(&amp;lt;* &amp;gt;){/^(\w+)\d+$/ or next;open$x,"&amp;lt;$_";open$y,"&amp;gt;&amp;gt;${1}00000";print$y &amp;lt;$x&amp;gt;}'&lt;BR /&gt;&lt;BR /&gt;unchecked, untested. If taking this to production, add tests to the open calls.&lt;BR /&gt;&lt;BR /&gt;Enjoy, have FUN! H.Merijn</description>
      <pubDate>Tue, 14 Jan 2003 16:50:24 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-use-to-combine-several-files-into-one-files/m-p/2881114#M100927</guid>
      <dc:creator>H.Merijn Brand (procura</dc:creator>
      <dc:date>2003-01-14T16:50:24Z</dc:date>
    </item>
    <item>
      <title>Re: Shell script use to combine several files into one files</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-use-to-combine-several-files-into-one-files/m-p/2881115#M100928</link>
      <description># perl -e'local$/;for(&amp;lt;* &amp;gt;){/^([A-Z]+)\d+$/i or next;open$x,"&amp;lt;$_";open$y,"&amp;gt;&amp;gt;${1}00000";print$y &amp;lt;$x&amp;gt;}'&lt;BR /&gt;&lt;BR /&gt;unchecked, untested. If taking this to production, add tests to the open calls.&lt;BR /&gt;&lt;BR /&gt;Enjoy, have FUN! H.Merijn</description>
      <pubDate>Tue, 14 Jan 2003 16:50:55 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-use-to-combine-several-files-into-one-files/m-p/2881115#M100928</guid>
      <dc:creator>H.Merijn Brand (procura</dc:creator>
      <dc:date>2003-01-14T16:50:55Z</dc:date>
    </item>
    <item>
      <title>Re: Shell script use to combine several files into one files</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-use-to-combine-several-files-into-one-files/m-p/2881116#M100929</link>
      <description>Ignore the first. An Opera-7 glitch. sorry. N/A</description>
      <pubDate>Tue, 14 Jan 2003 16:51:57 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-use-to-combine-several-files-into-one-files/m-p/2881116#M100929</guid>
      <dc:creator>H.Merijn Brand (procura</dc:creator>
      <dc:date>2003-01-14T16:51:57Z</dc:date>
    </item>
    <item>
      <title>Re: Shell script use to combine several files into one files</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-use-to-combine-several-files-into-one-files/m-p/2881117#M100930</link>
      <description>Here is a perl script that takes in account to NOT process the XXX00000 file as part of the input. It also has the benefit of not having to call external processes to copy each file.&lt;BR /&gt;&lt;BR /&gt;HTH&lt;BR /&gt;&lt;BR /&gt;-- Rod Hills&lt;BR /&gt;&lt;BR /&gt;open(LIS,"ls -1|");&lt;BR /&gt;$prv=""&lt;BR /&gt;while(&lt;LIS&gt;) {&lt;BR /&gt; chomp;&lt;BR /&gt; $fil=$_;&lt;BR /&gt; next if substr($fil,3,5) eq "00000" ;# ignore result file&lt;BR /&gt; $cur=substr($fil,0,3);&lt;BR /&gt; if ($prv ne $cur) {&lt;BR /&gt;  close OUT if $prv;&lt;BR /&gt;  open(OUT,"&amp;gt;${cur}00000");&lt;BR /&gt;  $prv=$cur;&lt;BR /&gt; }&lt;BR /&gt; open(INP,"&amp;lt;$fil");&lt;BR /&gt; while(&lt;INP&gt;) { print OUT $_; }&lt;BR /&gt; close INP;&lt;BR /&gt;}&lt;/INP&gt;&lt;/LIS&gt;</description>
      <pubDate>Tue, 14 Jan 2003 17:22:00 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-use-to-combine-several-files-into-one-files/m-p/2881117#M100930</guid>
      <dc:creator>Rodney Hills</dc:creator>
      <dc:date>2003-01-14T17:22:00Z</dc:date>
    </item>
    <item>
      <title>Re: Shell script use to combine several files into one files</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-use-to-combine-several-files-into-one-files/m-p/2881118#M100931</link>
      <description>Good catch Rodney!&lt;BR /&gt;&lt;BR /&gt;# perl -e'local$/;for(&amp;lt;* &amp;gt;){/^([A-Z]+)(\d+)$/i or next;$2&amp;gt;0 or next;open$x,"&amp;lt;$_";open$y,"&amp;gt;&amp;gt;${1}00000";print$y &amp;lt;$x&amp;gt;}'</description>
      <pubDate>Tue, 14 Jan 2003 19:35:16 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-use-to-combine-several-files-into-one-files/m-p/2881118#M100931</guid>
      <dc:creator>H.Merijn Brand (procura</dc:creator>
      <dc:date>2003-01-14T19:35:16Z</dc:date>
    </item>
    <item>
      <title>Re: Shell script use to combine several files into one files</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-use-to-combine-several-files-into-one-files/m-p/2881119#M100932</link>
      <description>Really thanks a lot.&lt;BR /&gt;&lt;BR /&gt;I did the script by reference your examples. Here:&lt;BR /&gt;&lt;BR /&gt;for i in (`ls -1 *[0-9][0-9][0-9][0-9][0-9][0-9]|sort -u)&lt;BR /&gt;do &lt;BR /&gt;cat ${i}* &amp;gt;&amp;gt; ${i}00000 &lt;BR /&gt;done &lt;BR /&gt;&lt;BR /&gt;Happy scripting!&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 15 Jan 2003 02:24:00 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-use-to-combine-several-files-into-one-files/m-p/2881119#M100932</guid>
      <dc:creator>wfalai</dc:creator>
      <dc:date>2003-01-15T02:24:00Z</dc:date>
    </item>
  </channel>
</rss>

