<?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: file sorting question in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/file-sorting-question/m-p/3202628#M166944</link>
    <description>perl -ne '($a,$b,$c)=split //;print "c${a}d${b}t${c}\n"' datafile&lt;BR /&gt; &lt;BR /&gt;I had to offer this perl version if only so that I can learn something when Merijn pops in and does it using some perl construct I've never heard of.</description>
    <pubDate>Thu, 26 Feb 2004 01:36:32 GMT</pubDate>
    <dc:creator>Mark Grant</dc:creator>
    <dc:date>2004-02-26T01:36:32Z</dc:date>
    <item>
      <title>file sorting question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/file-sorting-question/m-p/3202622#M166938</link>
      <description>Hi all &lt;BR /&gt;&lt;BR /&gt;easy one here, its 4:00am and I can't seem to think!!&lt;BR /&gt;&lt;BR /&gt;I have a file that contains&lt;BR /&gt;&lt;BR /&gt;123&lt;BR /&gt;456&lt;BR /&gt;789&lt;BR /&gt;&lt;BR /&gt;etc etc&lt;BR /&gt;&lt;BR /&gt;I need to read the file and output&lt;BR /&gt;&lt;BR /&gt;c1t2d3&lt;BR /&gt;&lt;BR /&gt;etc etc&lt;BR /&gt;&lt;BR /&gt;My problem is I have no delimeter and am struggling&lt;BR /&gt;&lt;BR /&gt;cheers&lt;BR /&gt;&lt;BR /&gt;Steve</description>
      <pubDate>Wed, 25 Feb 2004 23:09:16 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/file-sorting-question/m-p/3202622#M166938</guid>
      <dc:creator>steven Burgess_2</dc:creator>
      <dc:date>2004-02-25T23:09:16Z</dc:date>
    </item>
    <item>
      <title>Re: file sorting question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/file-sorting-question/m-p/3202623#M166939</link>
      <description>Try the cut command.  I'm not sure if I'll get the syntax correct but you should be able to figure it out.&lt;BR /&gt;&lt;BR /&gt;for i in $(cat file)&lt;BR /&gt;do&lt;BR /&gt;C=$(echo ${i} | cut -c 1)&lt;BR /&gt;D=$(echo ${i} | cut -c 2)&lt;BR /&gt;T=$(echo ${i} | cut -c 3)&lt;BR /&gt;DEVICE=c${C}d${D}t${T}&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;I think that should work.&lt;BR /&gt;&lt;BR /&gt;Good luck</description>
      <pubDate>Wed, 25 Feb 2004 23:20:54 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/file-sorting-question/m-p/3202623#M166939</guid>
      <dc:creator>Patrick Wallek</dc:creator>
      <dc:date>2004-02-25T23:20:54Z</dc:date>
    </item>
    <item>
      <title>Re: file sorting question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/file-sorting-question/m-p/3202624#M166940</link>
      <description>Oops...I ommitted the echo from the little script.  Before the done statement put in:&lt;BR /&gt;&lt;BR /&gt;echo ${DEVICE}&lt;BR /&gt;&lt;BR /&gt;I just did a quick test and that does work.</description>
      <pubDate>Wed, 25 Feb 2004 23:25:43 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/file-sorting-question/m-p/3202624#M166940</guid>
      <dc:creator>Patrick Wallek</dc:creator>
      <dc:date>2004-02-25T23:25:43Z</dc:date>
    </item>
    <item>
      <title>Re: file sorting question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/file-sorting-question/m-p/3202625#M166941</link>
      <description>Cheers Patrick&lt;BR /&gt;&lt;BR /&gt;should have thought of that really as I am using a cut in the preceding pipe to get the above info...doh!&lt;BR /&gt;&lt;BR /&gt;Steve</description>
      <pubDate>Wed, 25 Feb 2004 23:28:27 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/file-sorting-question/m-p/3202625#M166941</guid>
      <dc:creator>steven Burgess_2</dc:creator>
      <dc:date>2004-02-25T23:28:27Z</dc:date>
    </item>
    <item>
      <title>Re: file sorting question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/file-sorting-question/m-p/3202626#M166942</link>
      <description>Steve,&lt;BR /&gt;&lt;BR /&gt;My 2 cents.&lt;BR /&gt;&lt;BR /&gt;If you are the one who is generating the input file, then I suggest you add a delimiter for c,t and d values. For ex., if you are making a file using the device files c1t2d3, c2t10d4 and c12t0d1, then your input file will become &lt;BR /&gt;&lt;BR /&gt;123&lt;BR /&gt;2104&lt;BR /&gt;1201&lt;BR /&gt;&lt;BR /&gt;It's just difficult to get back the original device files from the above. Where in, if you put a delimiter like : &lt;BR /&gt;1:2:3&lt;BR /&gt;2:10:4&lt;BR /&gt;12:0:1&lt;BR /&gt;&lt;BR /&gt;It's really easy to get back the original device files. &lt;BR /&gt;&lt;BR /&gt;I don't know your requirements but I am just cautioning for such cases in future.&lt;BR /&gt;&lt;BR /&gt;-Sri</description>
      <pubDate>Thu, 26 Feb 2004 00:28:25 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/file-sorting-question/m-p/3202626#M166942</guid>
      <dc:creator>Sridhar Bhaskarla</dc:creator>
      <dc:date>2004-02-26T00:28:25Z</dc:date>
    </item>
    <item>
      <title>Re: file sorting question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/file-sorting-question/m-p/3202627#M166943</link>
      <description>how about&lt;BR /&gt;&lt;BR /&gt;for i in $(cat file)&lt;BR /&gt;do&lt;BR /&gt;device=$(echo ${i} | sed -e 's/\(.\)\(.\)\(.\)/c\1t\2d\3/')&lt;BR /&gt;print $device&lt;BR /&gt;done&lt;BR /&gt;</description>
      <pubDate>Thu, 26 Feb 2004 01:08:37 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/file-sorting-question/m-p/3202627#M166943</guid>
      <dc:creator>curt larson_1</dc:creator>
      <dc:date>2004-02-26T01:08:37Z</dc:date>
    </item>
    <item>
      <title>Re: file sorting question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/file-sorting-question/m-p/3202628#M166944</link>
      <description>perl -ne '($a,$b,$c)=split //;print "c${a}d${b}t${c}\n"' datafile&lt;BR /&gt; &lt;BR /&gt;I had to offer this perl version if only so that I can learn something when Merijn pops in and does it using some perl construct I've never heard of.</description>
      <pubDate>Thu, 26 Feb 2004 01:36:32 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/file-sorting-question/m-p/3202628#M166944</guid>
      <dc:creator>Mark Grant</dc:creator>
      <dc:date>2004-02-26T01:36:32Z</dc:date>
    </item>
    <item>
      <title>Re: file sorting question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/file-sorting-question/m-p/3202629#M166945</link>
      <description>Or use sed:&lt;BR /&gt;&lt;BR /&gt;sed 's/\(.\)\(.\)\(.\)/c\1t\2d\3/g'&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 26 Feb 2004 01:42:41 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/file-sorting-question/m-p/3202629#M166945</guid>
      <dc:creator>Elmar P. Kolkman</dc:creator>
      <dc:date>2004-02-26T01:42:41Z</dc:date>
    </item>
    <item>
      <title>Re: file sorting question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/file-sorting-question/m-p/3202630#M166946</link>
      <description>Oops, I missed the fact that someone else also gave the sed solution.&lt;BR /&gt;But mind: you don't have to do the for loop. Just do: cat $file | sed ...&lt;BR /&gt;Or even:&lt;BR /&gt;sed ... &amp;lt; $file&lt;BR /&gt;&lt;BR /&gt;One thing to bear in mind: it only will work with target ID's below 10.&lt;BR /&gt;&lt;BR /&gt;If you have large target id's, the length of the string can be 3 or 4 characters, meaning the sed statement has to be changed:&lt;BR /&gt;cat $file | sed 's/^\(.\)\(.*\)\(.\)$/c\1t\2d\3/'&lt;BR /&gt;&lt;BR /&gt;Which will put the first and last character in the buffers 1 and 3 and all characters in between in buffer 2. That is also why you will need the carrot and dollar sign now.</description>
      <pubDate>Thu, 26 Feb 2004 02:53:04 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/file-sorting-question/m-p/3202630#M166946</guid>
      <dc:creator>Elmar P. Kolkman</dc:creator>
      <dc:date>2004-02-26T02:53:04Z</dc:date>
    </item>
    <item>
      <title>Re: file sorting question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/file-sorting-question/m-p/3202631#M166947</link>
      <description>And wheely got me. I know of several ways to do it, but this sed is just simply the easiest and fasted way&lt;BR /&gt;&lt;BR /&gt;playing golf, one can loose the anchors&lt;BR /&gt;&lt;BR /&gt;# sed 's/\(.\)\(.*\)\(.\)/c\1t\2d\3/' &lt;FILE&gt;&lt;/FILE&gt;&lt;BR /&gt;in perl one can loose more characters, but in basics it is the same&lt;BR /&gt;&lt;BR /&gt;# perl -pe's/(.)(.)(.)/c$1t$2d$3/' file&lt;BR /&gt;&lt;BR /&gt;obfuscation only makes it longer. But if you *know* that each line always is ^\d\d\d$, you can play a wicked game by dropping the last capture:&lt;BR /&gt;&lt;BR /&gt;# perl -pe's/(.)(.)/c$1t$2d/' file&lt;BR /&gt;&lt;BR /&gt;Enjoy, Have FUN! H.Merijn</description>
      <pubDate>Thu, 26 Feb 2004 03:21:44 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/file-sorting-question/m-p/3202631#M166947</guid>
      <dc:creator>H.Merijn Brand (procura</dc:creator>
      <dc:date>2004-02-26T03:21:44Z</dc:date>
    </item>
  </channel>
</rss>

