<?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 manipulation scripting in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/file-manipulation-scripting/m-p/2958491#M117744</link>
    <description>I want to thank everyone who replied.  All of your suggestions were helpful.  I see that I need to get some good learning sources on PERL and shell scripting if I am going to be working in UNIX.&lt;BR /&gt;&lt;BR /&gt;Greg</description>
    <pubDate>Thu, 24 Apr 2003 12:28:15 GMT</pubDate>
    <dc:creator>Gregory F. Wright</dc:creator>
    <dc:date>2003-04-24T12:28:15Z</dc:date>
    <item>
      <title>file manipulation scripting</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/file-manipulation-scripting/m-p/2958485#M117738</link>
      <description>Hi,&lt;BR /&gt;I am new to unix so be kind.  I have a text file that I need to modify.  Each line in the file consists of groups of data to be read by another program.  What I need to do is to add a new group at the beginning of each line in the form:&lt;BR /&gt;IIP## , where ## is a sequence number that is incremented for each line.  I also need to append an "=" character to the last group of each line.  The number of lines in each file is variable.&lt;BR /&gt;Can this be easily done with scripting or do I need to write a program to do this?&lt;BR /&gt;&lt;BR /&gt;Greg Wright</description>
      <pubDate>Thu, 24 Apr 2003 11:08:27 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/file-manipulation-scripting/m-p/2958485#M117738</guid>
      <dc:creator>Gregory F. Wright</dc:creator>
      <dc:date>2003-04-24T11:08:27Z</dc:date>
    </item>
    <item>
      <title>Re: file manipulation scripting</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/file-manipulation-scripting/m-p/2958486#M117739</link>
      <description>Let me count the ways ... &lt;BR /&gt;&lt;BR /&gt;This can be shell scripted, perl'd, C'd, etc'd.&lt;BR /&gt;&lt;BR /&gt;Use what you're comfortable with; use what you know.  If you don't know any of the aforementioned, use shell or perl.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 24 Apr 2003 11:12:57 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/file-manipulation-scripting/m-p/2958486#M117739</guid>
      <dc:creator>Christopher Caldwell</dc:creator>
      <dc:date>2003-04-24T11:12:57Z</dc:date>
    </item>
    <item>
      <title>Re: file manipulation scripting</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/file-manipulation-scripting/m-p/2958487#M117740</link>
      <description>Hi Greg,&lt;BR /&gt;&lt;BR /&gt;As mentioned, loads of ways, but here's an awk method:&lt;BR /&gt;&lt;BR /&gt;awk '{printf("IIP%02d %s=\n",NR,$0)}' filename&lt;BR /&gt;&lt;BR /&gt;rgds, Robin</description>
      <pubDate>Thu, 24 Apr 2003 11:15:44 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/file-manipulation-scripting/m-p/2958487#M117740</guid>
      <dc:creator>Robin Wakefield</dc:creator>
      <dc:date>2003-04-24T11:15:44Z</dc:date>
    </item>
    <item>
      <title>Re: file manipulation scripting</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/file-manipulation-scripting/m-p/2958488#M117741</link>
      <description>in perl you can do something like&lt;BR /&gt;&lt;BR /&gt;while (&amp;lt;&amp;gt;) {&lt;BR /&gt;    chomp;      # strip record separator&lt;BR /&gt;        printf "IIP%02d %s=\n", $., $_;&lt;BR /&gt;    print $_ if $filename;&lt;BR /&gt;}</description>
      <pubDate>Thu, 24 Apr 2003 11:40:56 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/file-manipulation-scripting/m-p/2958488#M117741</guid>
      <dc:creator>Paddy_1</dc:creator>
      <dc:date>2003-04-24T11:40:56Z</dc:date>
    </item>
    <item>
      <title>Re: file manipulation scripting</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/file-manipulation-scripting/m-p/2958489#M117742</link>
      <description>Hi Greg,&lt;BR /&gt;a simple standard script can probably also do it, e.g.:&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;typeset -i NUMBER=0&lt;BR /&gt;while read line&lt;BR /&gt;do&lt;BR /&gt;        let NUMBER="$NUMBER + 1"&lt;BR /&gt;        echo "IIP${NUMBER} ${line}="&lt;BR /&gt;done &amp;lt;$1&lt;BR /&gt;&lt;BR /&gt;Run it like this:&lt;BR /&gt;# simple_script.sh inputfile &amp;gt;new_out&lt;BR /&gt;&lt;BR /&gt;to redirect the result to  new_out&lt;BR /&gt;&lt;BR /&gt;regards,&lt;BR /&gt;John K.&lt;BR /&gt;</description>
      <pubDate>Thu, 24 Apr 2003 11:43:07 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/file-manipulation-scripting/m-p/2958489#M117742</guid>
      <dc:creator>john korterman</dc:creator>
      <dc:date>2003-04-24T11:43:07Z</dc:date>
    </item>
    <item>
      <title>Re: file manipulation scripting</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/file-manipulation-scripting/m-p/2958490#M117743</link>
      <description>He guys,&lt;BR /&gt;&lt;BR /&gt;He asked us to be nice !&lt;BR /&gt;&lt;BR /&gt;Looking at just one file you want to look at :&lt;BR /&gt;&lt;BR /&gt;#!/opt/perl/bin/perl&lt;BR /&gt;&lt;BR /&gt;$file="/etc/hosts";&lt;BR /&gt;$file2="/tmp/file2";&lt;BR /&gt;&lt;BR /&gt;# Open source file for read only mode&lt;BR /&gt;open(FH, "&amp;lt; $file");&lt;BR /&gt;&lt;BR /&gt;# Open destination file in write mode&lt;BR /&gt;open(FD, "&amp;gt; $file2");&lt;BR /&gt;&lt;BR /&gt;$num = 0;&lt;BR /&gt;while(&lt;FH&gt;) {&lt;BR /&gt;&lt;BR /&gt;  # Set $num to value + 1&lt;BR /&gt;  $num++;&lt;BR /&gt;&lt;BR /&gt;  # Add the number to the beginning of the line&lt;BR /&gt;  $_ = "IIP $num" . $_ ;&lt;BR /&gt;  # Add a = to the end of the line&lt;BR /&gt;  s/\n//;&lt;BR /&gt;  $_ = $_ . "\= \n";&lt;BR /&gt;&lt;BR /&gt;  # Now store the current line into file2&lt;BR /&gt;  print FH "$_" ;&lt;BR /&gt;  # An print it on screen&lt;BR /&gt;  print $_;&lt;BR /&gt;&lt;BR /&gt;} # end of the while loop (so end of file)&lt;BR /&gt;&lt;BR /&gt;# Dont forget to close both Files&lt;BR /&gt;close(FH);&lt;BR /&gt;close(FD);&lt;BR /&gt;&lt;BR /&gt;print "Alright, done checking $file. \n";&lt;BR /&gt;print "File had $num lines \n"&lt;BR /&gt;&lt;BR /&gt;----------------------&lt;BR /&gt;&lt;BR /&gt;If you need any more info, please let us know.&lt;BR /&gt;&lt;BR /&gt;Best Regs David&lt;/FH&gt;</description>
      <pubDate>Thu, 24 Apr 2003 12:05:01 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/file-manipulation-scripting/m-p/2958490#M117743</guid>
      <dc:creator>David_246</dc:creator>
      <dc:date>2003-04-24T12:05:01Z</dc:date>
    </item>
    <item>
      <title>Re: file manipulation scripting</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/file-manipulation-scripting/m-p/2958491#M117744</link>
      <description>I want to thank everyone who replied.  All of your suggestions were helpful.  I see that I need to get some good learning sources on PERL and shell scripting if I am going to be working in UNIX.&lt;BR /&gt;&lt;BR /&gt;Greg</description>
      <pubDate>Thu, 24 Apr 2003 12:28:15 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/file-manipulation-scripting/m-p/2958491#M117744</guid>
      <dc:creator>Gregory F. Wright</dc:creator>
      <dc:date>2003-04-24T12:28:15Z</dc:date>
    </item>
    <item>
      <title>Re: file manipulation scripting</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/file-manipulation-scripting/m-p/2958492#M117745</link>
      <description>Hi again,&lt;BR /&gt;&lt;BR /&gt;Since I do not have PERL on my system I tried the AWK and shell script methods.  Both worked, or would have if I had included the following information. Each line ends with an CR character.  This causes the AWK method to place the '=' character at the beginning of each line (overwriting the first I in IIP) and the shell scripting method to place the '=' after the CR character.&lt;BR /&gt;&lt;BR /&gt;In the AWK method I tried \b between the %s and = characters but it didn't work.&lt;BR /&gt;&lt;BR /&gt;Any further solutions?  I need method of stripping out the CR at the end of each line.&lt;BR /&gt;&lt;BR /&gt;Greg</description>
      <pubDate>Thu, 24 Apr 2003 13:37:40 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/file-manipulation-scripting/m-p/2958492#M117745</guid>
      <dc:creator>Gregory F. Wright</dc:creator>
      <dc:date>2003-04-24T13:37:40Z</dc:date>
    </item>
    <item>
      <title>Re: file manipulation scripting</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/file-manipulation-scripting/m-p/2958493#M117746</link>
      <description>You don't have perl? Uhh, look again, you *do* have perl (/usr/contrib/bin/perl), but that is an old version (version 4).&lt;BR /&gt;&lt;BR /&gt;Perl is free, and IMHO indispensable for an SA.&lt;BR /&gt;&lt;BR /&gt;Get it (perl 5.8.0) from your latest Application CD's, from &lt;A href="http://hpux.connect.org.uk/hppd/hpux/Languages/perl-5.8.0/" target="_blank"&gt;http://hpux.connect.org.uk/hppd/hpux/Languages/perl-5.8.0/&lt;/A&gt; or from &lt;A href="https://www.beepz.com/personal/merijn/" target="_blank"&gt;https://www.beepz.com/personal/merijn/&lt;/A&gt; or &lt;A href="http://www.cmve.net/~merijn/" target="_blank"&gt;http://www.cmve.net/~merijn/&lt;/A&gt;&lt;BR /&gt;and enjoy it's rich set of features.&lt;BR /&gt;&lt;BR /&gt;Enjoy, have FUN! H.Merijn</description>
      <pubDate>Thu, 24 Apr 2003 13:46:32 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/file-manipulation-scripting/m-p/2958493#M117746</guid>
      <dc:creator>H.Merijn Brand (procura</dc:creator>
      <dc:date>2003-04-24T13:46:32Z</dc:date>
    </item>
    <item>
      <title>Re: file manipulation scripting</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/file-manipulation-scripting/m-p/2958494#M117747</link>
      <description>Hi Greg:&lt;BR /&gt;&lt;BR /&gt;If you have carriage return characters in your file then you undoubtedly transferred it from Windows using FTP but in binary mode.  Text file transfers from Unix to/from Windows should be done in ASCII mode.  This converts the Windows linefeed/carriage-return to a Unix newline character and vice versa.&lt;BR /&gt;&lt;BR /&gt;You can also correct your file on the Unix server with:&lt;BR /&gt;&lt;BR /&gt;# dos2ux &amp;lt; filename &amp;gt; filename.new&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Thu, 24 Apr 2003 13:48:31 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/file-manipulation-scripting/m-p/2958494#M117747</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2003-04-24T13:48:31Z</dc:date>
    </item>
    <item>
      <title>Re: file manipulation scripting</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/file-manipulation-scripting/m-p/2958495#M117748</link>
      <description>Hi&lt;BR /&gt;&lt;BR /&gt;A stupid one&lt;BR /&gt;&lt;BR /&gt;mv file /tmp/file&lt;BR /&gt;nl -ba -nln /tmp/file|while read line&lt;BR /&gt;do&lt;BR /&gt;echo "IIP"$line"="&lt;BR /&gt;done &amp;gt; file&lt;BR /&gt;/bin/rm /tmp/file&lt;BR /&gt;&lt;BR /&gt;              Steve Steel&lt;BR /&gt;&lt;BR /&gt;Do not make our input pointless. Give points to the ones you like.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 24 Apr 2003 13:50:36 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/file-manipulation-scripting/m-p/2958495#M117748</guid>
      <dc:creator>Steve Steel</dc:creator>
      <dc:date>2003-04-24T13:50:36Z</dc:date>
    </item>
    <item>
      <title>Re: file manipulation scripting</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/file-manipulation-scripting/m-p/2958496#M117749</link>
      <description>Hi Greg,&lt;BR /&gt;&lt;BR /&gt;You could also remove the CRs within awk:&lt;BR /&gt;&lt;BR /&gt;awk '{sub("\r","");printf("IIP%02d %s=\n",NR,$0)}' filename&lt;BR /&gt;&lt;BR /&gt;rgds, Robin</description>
      <pubDate>Thu, 24 Apr 2003 14:29:48 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/file-manipulation-scripting/m-p/2958496#M117749</guid>
      <dc:creator>Robin Wakefield</dc:creator>
      <dc:date>2003-04-24T14:29:48Z</dc:date>
    </item>
  </channel>
</rss>

