<?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 cron question in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/cron-question/m-p/3575442#M228889</link>
    <description>I'm going to setup a cron job that creates a large file.  I need to insert a line of text that looks like this "" as the second line in this file.&lt;BR /&gt;&lt;BR /&gt;How can I do this from a command line?</description>
    <pubDate>Sun, 03 Jul 2005 18:00:18 GMT</pubDate>
    <dc:creator>Rob Johnson_3</dc:creator>
    <dc:date>2005-07-03T18:00:18Z</dc:date>
    <item>
      <title>cron question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/cron-question/m-p/3575442#M228889</link>
      <description>I'm going to setup a cron job that creates a large file.  I need to insert a line of text that looks like this "" as the second line in this file.&lt;BR /&gt;&lt;BR /&gt;How can I do this from a command line?</description>
      <pubDate>Sun, 03 Jul 2005 18:00:18 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/cron-question/m-p/3575442#M228889</guid>
      <dc:creator>Rob Johnson_3</dc:creator>
      <dc:date>2005-07-03T18:00:18Z</dc:date>
    </item>
    <item>
      <title>Re: cron question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/cron-question/m-p/3575443#M228890</link>
      <description>Mmmmm if I understand correctly, you don't want to create a second tempfile for space reasons but insert directly this line in. This is not possible. Even if you go more low-level than the usual tools you'll just be able to append to the file or overwrite parts of it.&lt;BR /&gt;&lt;BR /&gt;If you really cannot write in a tempfile, the only solution is to leave space in your file upon creation to hold this second line. You can leave a long empty string at line 2, ended by a newline. Then you can open it, goto line 2 and replace it with your string, padded to have the same length. I don't think any shell tool can pull this off easily, so I suggest you try perl. :)&lt;BR /&gt;&lt;BR /&gt;If you can write to another file, the simplest way I can think of is using awk like this:&lt;BR /&gt;&lt;BR /&gt;cat original_file | awk '{&lt;BR /&gt;    print;&lt;BR /&gt;    print "";&lt;BR /&gt;    while (getline)&lt;BR /&gt;    {&lt;BR /&gt;         print;&lt;BR /&gt;    }&lt;BR /&gt;}' &amp;gt; new_file&lt;BR /&gt;mv new_file original_file&lt;BR /&gt;&lt;BR /&gt;I don't have a prompt at hand so there might be a syntax error or two.&lt;BR /&gt;&lt;BR /&gt;Good luck</description>
      <pubDate>Sun, 03 Jul 2005 20:40:51 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/cron-question/m-p/3575443#M228890</guid>
      <dc:creator>Olivier Masse</dc:creator>
      <dc:date>2005-07-03T20:40:51Z</dc:date>
    </item>
    <item>
      <title>Re: cron question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/cron-question/m-p/3575444#M228891</link>
      <description>Okay, lets try.&lt;BR /&gt;Can't give a full solution but maybe some points might click.&lt;BR /&gt;&lt;BR /&gt;Since cron will be writing to that file, you can't do anything with that otherwise your cron will stop.&lt;BR /&gt;&lt;BR /&gt;So use "fuser" to find out whether at that moment that file is being used. If not append the line after the first one.&lt;BR /&gt;&lt;BR /&gt;It can be done by sed but at the moment i don't remember the syntax.&lt;BR /&gt;&lt;BR /&gt;So something like&lt;BR /&gt;if fuser filename&lt;BR /&gt;then &lt;BR /&gt;sed ...&lt;BR /&gt;fi</description>
      <pubDate>Sun, 03 Jul 2005 23:58:04 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/cron-question/m-p/3575444#M228891</guid>
      <dc:creator>Vibhor Kumar Agarwal</dc:creator>
      <dc:date>2005-07-03T23:58:04Z</dc:date>
    </item>
    <item>
      <title>Re: cron question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/cron-question/m-p/3575445#M228892</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;what about this? zz is old and zz1 is new file.&lt;BR /&gt;&lt;BR /&gt;greetings,&lt;BR /&gt;&lt;BR /&gt;Michael&lt;BR /&gt;&lt;BR /&gt;#!/bin/ksh -xu&lt;BR /&gt;typeset -i10 LC=`wc -l zz|awk '{print $1}'`&lt;BR /&gt;let LC=LC-1&lt;BR /&gt;head -1 zz &amp;gt; zz1&lt;BR /&gt;print "insert line" &amp;gt;&amp;gt; zz1&lt;BR /&gt;tail -${LC} zz &amp;gt;&amp;gt; zz1&lt;BR /&gt;mv zz1 zz</description>
      <pubDate>Mon, 04 Jul 2005 06:28:10 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/cron-question/m-p/3575445#M228892</guid>
      <dc:creator>Michael Schulte zur Sur</dc:creator>
      <dc:date>2005-07-04T06:28:10Z</dc:date>
    </item>
    <item>
      <title>Re: cron question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/cron-question/m-p/3575446#M228893</link>
      <description>Will this make any difference?  I found out I can insert the text at the beggining of the file.  Will this make it easier?&lt;BR /&gt; &lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 04 Jul 2005 06:36:09 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/cron-question/m-p/3575446#M228893</guid>
      <dc:creator>Rob Johnson_3</dc:creator>
      <dc:date>2005-07-04T06:36:09Z</dc:date>
    </item>
    <item>
      <title>Re: cron question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/cron-question/m-p/3575447#M228894</link>
      <description>Perhaps you could alter the cron job, so that you start by creating a new file with this line, and then append to this file ?</description>
      <pubDate>Mon, 04 Jul 2005 06:54:18 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/cron-question/m-p/3575447#M228894</guid>
      <dc:creator>Kasper Hedensted</dc:creator>
      <dc:date>2005-07-04T06:54:18Z</dc:date>
    </item>
    <item>
      <title>Re: cron question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/cron-question/m-p/3575448#M228895</link>
      <description>I think you have given yourself a good idea.&lt;BR /&gt;&lt;BR /&gt;So you can create the file as&lt;BR /&gt;touch exp&lt;BR /&gt;sed -e 's/text_to_replace/^/g'&lt;BR /&gt;&lt;BR /&gt;Now start your cron job, which will add test to this file.&lt;BR /&gt;&lt;BR /&gt;When your cron has completed, if you really want this to be 2nd one, add the first line using the same sed command.</description>
      <pubDate>Mon, 04 Jul 2005 07:05:20 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/cron-question/m-p/3575448#M228895</guid>
      <dc:creator>Vibhor Kumar Agarwal</dc:creator>
      <dc:date>2005-07-04T07:05:20Z</dc:date>
    </item>
    <item>
      <title>Re: cron question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/cron-question/m-p/3575449#M228896</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;this makes it a lot easier&lt;BR /&gt;print "insert line" &amp;gt; new_file&lt;BR /&gt;cat old_file &amp;gt;&amp;gt; new_file&lt;BR /&gt;&lt;BR /&gt;Michael&lt;BR /&gt;</description>
      <pubDate>Mon, 04 Jul 2005 07:14:17 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/cron-question/m-p/3575449#M228896</guid>
      <dc:creator>Michael Schulte zur Sur</dc:creator>
      <dc:date>2005-07-04T07:14:17Z</dc:date>
    </item>
    <item>
      <title>Re: cron question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/cron-question/m-p/3575450#M228897</link>
      <description>I'm not at work and don't have a unix box here at home so I'm not sure which way will work best.  These responses have given me a lot of suggestions and options.  &lt;BR /&gt;&lt;BR /&gt;I love this forum.  When I post here, I always get a solution or plenty of good ideas to solve the issue at hand!!!&lt;BR /&gt;&lt;BR /&gt;Again, thank you from the guy who wishes he was a scripter!!!!!  &lt;BR /&gt;Chuckle, chuckle, chuckle....</description>
      <pubDate>Mon, 04 Jul 2005 08:20:40 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/cron-question/m-p/3575450#M228897</guid>
      <dc:creator>Rob Johnson_3</dc:creator>
      <dc:date>2005-07-04T08:20:40Z</dc:date>
    </item>
  </channel>
</rss>

