<?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: data manipulation in the file in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/data-manipulation-in-the-file/m-p/5033602#M95071</link>
    <description>Dennis,&lt;BR /&gt;what does ^\(....\)...    mean?&lt;BR /&gt;is it the range?&lt;BR /&gt;5th,6th and 7th character....how do i specify?:(</description>
    <pubDate>Wed, 14 Mar 2007 01:31:04 GMT</pubDate>
    <dc:creator>Reen</dc:creator>
    <dc:date>2007-03-14T01:31:04Z</dc:date>
    <item>
      <title>data manipulation in the file</title>
      <link>https://community.hpe.com/t5/operating-system-linux/data-manipulation-in-the-file/m-p/5033587#M95056</link>
      <description>How can i replace data in a file without opening it?&lt;BR /&gt;I want the 5th,6th and 7th character in a file to be replaced by a string&lt;BR /&gt;Can anybody help me??</description>
      <pubDate>Tue, 13 Mar 2007 05:52:14 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/data-manipulation-in-the-file/m-p/5033587#M95056</guid>
      <dc:creator>Reen</dc:creator>
      <dc:date>2007-03-13T05:52:14Z</dc:date>
    </item>
    <item>
      <title>Re: data manipulation in the file</title>
      <link>https://community.hpe.com/t5/operating-system-linux/data-manipulation-in-the-file/m-p/5033588#M95057</link>
      <description>Hi,&lt;BR /&gt;and welcome to the forums !&lt;BR /&gt;What do you mean by "without opening" ?&lt;BR /&gt;In order to read the data you have to open the file!&lt;BR /&gt;&lt;BR /&gt;You can read this earlier thread with a similar problem:&lt;BR /&gt;&lt;A href="http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=1107862" target="_blank"&gt;http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=1107862&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Please also read:&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; on how to reward any useful answers given to your questions.&lt;BR /&gt;</description>
      <pubDate>Tue, 13 Mar 2007 06:01:19 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/data-manipulation-in-the-file/m-p/5033588#M95057</guid>
      <dc:creator>Peter Godron</dc:creator>
      <dc:date>2007-03-13T06:01:19Z</dc:date>
    </item>
    <item>
      <title>Re: data manipulation in the file</title>
      <link>https://community.hpe.com/t5/operating-system-linux/data-manipulation-in-the-file/m-p/5033589#M95058</link>
      <description>Hi Peter,&lt;BR /&gt;Thank u so much for the welcum&lt;BR /&gt;and bout the query..&lt;BR /&gt;the link dint help.&lt;BR /&gt;here i dont know wat these 5th, 6th and 7th characters are, i just want them replaced&lt;BR /&gt;&lt;BR /&gt;and what i meant by saying without opening the file is that, if u open a file in any editor, its not a prob to replace a character</description>
      <pubDate>Tue, 13 Mar 2007 06:09:47 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/data-manipulation-in-the-file/m-p/5033589#M95058</guid>
      <dc:creator>Reen</dc:creator>
      <dc:date>2007-03-13T06:09:47Z</dc:date>
    </item>
    <item>
      <title>Re: data manipulation in the file</title>
      <link>https://community.hpe.com/t5/operating-system-linux/data-manipulation-in-the-file/m-p/5033590#M95059</link>
      <description>Hi,&lt;BR /&gt;if you want to change 5-7 char of each line:&lt;BR /&gt;perl -ple 'substr($_,4,3,"abc")' g.lis &amp;gt; h.lis&lt;BR /&gt;&lt;BR /&gt;Example:&lt;BR /&gt;input (g.lis)&lt;BR /&gt;12399456&lt;BR /&gt;12398456&lt;BR /&gt;output (h.lis)&lt;BR /&gt;1239abc6&lt;BR /&gt;1239abc6</description>
      <pubDate>Tue, 13 Mar 2007 06:20:24 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/data-manipulation-in-the-file/m-p/5033590#M95059</guid>
      <dc:creator>Peter Godron</dc:creator>
      <dc:date>2007-03-13T06:20:24Z</dc:date>
    </item>
    <item>
      <title>Re: data manipulation in the file</title>
      <link>https://community.hpe.com/t5/operating-system-linux/data-manipulation-in-the-file/m-p/5033591#M95060</link>
      <description>Hi,&lt;BR /&gt;or if you only want this to happen on the first line of the file:&lt;BR /&gt;&lt;BR /&gt;perl -ple 'substr($_,4,3,"abc") if $.==1' g.lis &amp;gt; h.lis</description>
      <pubDate>Tue, 13 Mar 2007 06:28:16 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/data-manipulation-in-the-file/m-p/5033591#M95060</guid>
      <dc:creator>Peter Godron</dc:creator>
      <dc:date>2007-03-13T06:28:16Z</dc:date>
    </item>
    <item>
      <title>Re: data manipulation in the file</title>
      <link>https://community.hpe.com/t5/operating-system-linux/data-manipulation-in-the-file/m-p/5033592#M95061</link>
      <description>Peter,&lt;BR /&gt;am really sorry.. i forgot to say i need the solution in shell scripting terms..&lt;BR /&gt;since i dont understand perl.&lt;BR /&gt;pls</description>
      <pubDate>Tue, 13 Mar 2007 06:33:30 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/data-manipulation-in-the-file/m-p/5033592#M95061</guid>
      <dc:creator>Reen</dc:creator>
      <dc:date>2007-03-13T06:33:30Z</dc:date>
    </item>
    <item>
      <title>Re: data manipulation in the file</title>
      <link>https://community.hpe.com/t5/operating-system-linux/data-manipulation-in-the-file/m-p/5033593#M95062</link>
      <description>Hi,&lt;BR /&gt;in that case the whole things gets a bit more complex. Can you please provide an example line of input, as we need to know if the data is split into fields etc.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 13 Mar 2007 06:43:15 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/data-manipulation-in-the-file/m-p/5033593#M95062</guid>
      <dc:creator>Peter Godron</dc:creator>
      <dc:date>2007-03-13T06:43:15Z</dc:date>
    </item>
    <item>
      <title>Re: data manipulation in the file</title>
      <link>https://community.hpe.com/t5/operating-system-linux/data-manipulation-in-the-file/m-p/5033594#M95063</link>
      <description>If you want to replace columns 5-7 of every line, you can use sed:&lt;BR /&gt;$ sed -e 's/^\(....\).../\1ABC/' file&lt;BR /&gt;&lt;BR /&gt;Where ABC is your replacement string.  It can be longer or shorter.  "\1" puts back the first 4 chars.</description>
      <pubDate>Tue, 13 Mar 2007 06:54:24 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/data-manipulation-in-the-file/m-p/5033594#M95063</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2007-03-13T06:54:24Z</dc:date>
    </item>
    <item>
      <title>Re: data manipulation in the file</title>
      <link>https://community.hpe.com/t5/operating-system-linux/data-manipulation-in-the-file/m-p/5033595#M95064</link>
      <description>Hi,&lt;BR /&gt;if sed is ok by you, could you please complete the thread by awarding points to helpful answers and summarising the solution for you. Otherwise please continue the thread.&lt;BR /&gt;&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; shows how to reward any useful answers given to your questions.</description>
      <pubDate>Tue, 13 Mar 2007 06:59:43 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/data-manipulation-in-the-file/m-p/5033595#M95064</guid>
      <dc:creator>Peter Godron</dc:creator>
      <dc:date>2007-03-13T06:59:43Z</dc:date>
    </item>
    <item>
      <title>Re: data manipulation in the file</title>
      <link>https://community.hpe.com/t5/operating-system-linux/data-manipulation-in-the-file/m-p/5033596#M95065</link>
      <description>I don't think that you can modify data in a file without opening it (even read only, and dumping a modified copy of its content).&lt;BR /&gt;When you use those shell redirections, as shown, the shell is doing the opening (and possibly clobbering) for you by system calls behind the scenes.&lt;BR /&gt;You could verify by attaching a syscall tracer like tusc, truss, or strace to your processes...&lt;BR /&gt;</description>
      <pubDate>Tue, 13 Mar 2007 07:37:50 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/data-manipulation-in-the-file/m-p/5033596#M95065</guid>
      <dc:creator>Ralph Grothe</dc:creator>
      <dc:date>2007-03-13T07:37:50Z</dc:date>
    </item>
    <item>
      <title>Re: data manipulation in the file</title>
      <link>https://community.hpe.com/t5/operating-system-linux/data-manipulation-in-the-file/m-p/5033597#M95066</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;&amp;gt;&amp;gt;&lt;BR /&gt;since i dont understand perl.&lt;BR /&gt;&amp;lt;&amp;lt;&lt;BR /&gt;&lt;BR /&gt;That does not matter, IMHO: There may be solutions in other languages, you won't understand, as well.&lt;BR /&gt;&lt;BR /&gt;We do not have your answer yet: Is the change of these characters required once in that file or in every line of it?&lt;BR /&gt;More questions:&lt;BR /&gt;- What about lines with less than 7 characters?&lt;BR /&gt;- Will newline charactes count?&lt;BR /&gt;&lt;BR /&gt;All line change:&lt;BR /&gt;nawk -v str=NEW '{print substr($0,1,4)""str""substr($0,8)}' infile&lt;BR /&gt;&lt;BR /&gt;mfG Peter</description>
      <pubDate>Tue, 13 Mar 2007 08:07:46 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/data-manipulation-in-the-file/m-p/5033597#M95066</guid>
      <dc:creator>Peter Nikitka</dc:creator>
      <dc:date>2007-03-13T08:07:46Z</dc:date>
    </item>
    <item>
      <title>Re: data manipulation in the file</title>
      <link>https://community.hpe.com/t5/operating-system-linux/data-manipulation-in-the-file/m-p/5033598#M95067</link>
      <description>&amp;gt;Peter: What do you mean by "without opening"? &lt;BR /&gt;&amp;gt;Ralph: I don't think that you can modify data in a file without opening it &lt;BR /&gt;&lt;BR /&gt;I can only assume that Reen@ meant the Windows open (run an editor or other magic program based on suffix) and not the nerd definition of open a file.</description>
      <pubDate>Tue, 13 Mar 2007 19:19:49 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/data-manipulation-in-the-file/m-p/5033598#M95067</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2007-03-13T19:19:49Z</dc:date>
    </item>
    <item>
      <title>Re: data manipulation in the file</title>
      <link>https://community.hpe.com/t5/operating-system-linux/data-manipulation-in-the-file/m-p/5033599#M95068</link>
      <description>Hi:&lt;BR /&gt;&lt;BR /&gt;Dennis wrote:&lt;BR /&gt;&lt;BR /&gt;&amp;gt; I can only assume that Reen@ meant the Windows open (run an editor or other magic program based on suffix) and not the nerd definition of open a file.&lt;BR /&gt;&lt;BR /&gt;Yes, of course.  Unless you can *open* a file, how else can you expect any process to *read* a stream of octets to perform any match and/or substitution!?!&lt;BR /&gt;&lt;BR /&gt;Depending upon the language, an implicit open() may be performed with a read() or write(), but that is purely under-the-covers slight-of-hand.  The '-p' Perl switch is actually performing an open() for the file name(s) specified as arguments to the script so this too counts as an open().  Ditto for the 'sed' and the 'awk' solutions.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Tue, 13 Mar 2007 19:32:18 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/data-manipulation-in-the-file/m-p/5033599#M95068</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2007-03-13T19:32:18Z</dc:date>
    </item>
    <item>
      <title>Re: data manipulation in the file</title>
      <link>https://community.hpe.com/t5/operating-system-linux/data-manipulation-in-the-file/m-p/5033600#M95069</link>
      <description>Ok..&lt;BR /&gt;I have attached the file.&lt;BR /&gt;I dont want the change to be done for all lines.&lt;BR /&gt;Only once i want the 5th,6th and 7th character to be replaced with say "AIR".&lt;BR /&gt;I have to do this change for many files. And these 3characters will be different for different files.&lt;BR /&gt;So, i wont know the characters to be replaced before hand itself.</description>
      <pubDate>Tue, 13 Mar 2007 22:45:55 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/data-manipulation-in-the-file/m-p/5033600#M95069</guid>
      <dc:creator>Reen</dc:creator>
      <dc:date>2007-03-13T22:45:55Z</dc:date>
    </item>
    <item>
      <title>Re: data manipulation in the file</title>
      <link>https://community.hpe.com/t5/operating-system-linux/data-manipulation-in-the-file/m-p/5033601#M95070</link>
      <description>&lt;!--!*#--&gt;&amp;gt;I dont want the change to be done for all lines.&lt;BR /&gt;&lt;BR /&gt;(Then you say you want it done for only the first line.)&lt;BR /&gt;&lt;BR /&gt;$ sed -e '1s/^\(....\).../\1AIR/' file&lt;BR /&gt;&lt;BR /&gt;This will create a new file, changing only the first line.  You would need to save the output and rename it to the original.&lt;BR /&gt;&lt;BR /&gt;for file in $*; do&lt;BR /&gt;   sed -e '1s/^\(....\).../\1AIR/' $file &amp;gt; $file.new&lt;BR /&gt;   mv $file.new $file&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;If the original is read-only, use "mv -f" above.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 14 Mar 2007 00:46:49 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/data-manipulation-in-the-file/m-p/5033601#M95070</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2007-03-14T00:46:49Z</dc:date>
    </item>
    <item>
      <title>Re: data manipulation in the file</title>
      <link>https://community.hpe.com/t5/operating-system-linux/data-manipulation-in-the-file/m-p/5033602#M95071</link>
      <description>Dennis,&lt;BR /&gt;what does ^\(....\)...    mean?&lt;BR /&gt;is it the range?&lt;BR /&gt;5th,6th and 7th character....how do i specify?:(</description>
      <pubDate>Wed, 14 Mar 2007 01:31:04 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/data-manipulation-in-the-file/m-p/5033602#M95071</guid>
      <dc:creator>Reen</dc:creator>
      <dc:date>2007-03-14T01:31:04Z</dc:date>
    </item>
    <item>
      <title>Re: data manipulation in the file</title>
      <link>https://community.hpe.com/t5/operating-system-linux/data-manipulation-in-the-file/m-p/5033603#M95072</link>
      <description>&amp;gt;what does ^\(....\)... mean?&lt;BR /&gt;&lt;BR /&gt;I mentioned that initially.  \( &amp;amp; \) assigns a number for the pattern inside, to the first 4 chars, then selects the next 3.  "." means it can be an arbitrary char.&lt;BR /&gt;&lt;BR /&gt;Then it puts the first 4 back with "\1", then your replacement string "AIR".</description>
      <pubDate>Wed, 14 Mar 2007 01:50:05 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/data-manipulation-in-the-file/m-p/5033603#M95072</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2007-03-14T01:50:05Z</dc:date>
    </item>
    <item>
      <title>Re: data manipulation in the file</title>
      <link>https://community.hpe.com/t5/operating-system-linux/data-manipulation-in-the-file/m-p/5033604#M95073</link>
      <description>Hi all,&lt;BR /&gt;I got a simple solution for this.&lt;BR /&gt;&lt;BR /&gt;cat file|cut -c5-7|read VAR1&lt;BR /&gt;sed "s/$VAR1/AIR/" file&lt;BR /&gt;&lt;BR /&gt;will work out fine.&lt;BR /&gt;Thanks a lot for the help and patience.&lt;BR /&gt;I will do the further procedures and close the thread.:-)</description>
      <pubDate>Wed, 14 Mar 2007 01:53:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/data-manipulation-in-the-file/m-p/5033604#M95073</guid>
      <dc:creator>Reen</dc:creator>
      <dc:date>2007-03-14T01:53:35Z</dc:date>
    </item>
    <item>
      <title>Re: data manipulation in the file</title>
      <link>https://community.hpe.com/t5/operating-system-linux/data-manipulation-in-the-file/m-p/5033605#M95074</link>
      <description>2 line command will work out</description>
      <pubDate>Wed, 14 Mar 2007 01:57:02 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/data-manipulation-in-the-file/m-p/5033605#M95074</guid>
      <dc:creator>Reen</dc:creator>
      <dc:date>2007-03-14T01:57:02Z</dc:date>
    </item>
    <item>
      <title>Re: data manipulation in the file</title>
      <link>https://community.hpe.com/t5/operating-system-linux/data-manipulation-in-the-file/m-p/5033606#M95075</link>
      <description>&amp;gt;cat file|cut -c5-7|read VAR1&lt;BR /&gt;sed "s/$VAR1/AIR/" file&lt;BR /&gt;&lt;BR /&gt;This depends on columns 5-7 of the first record not appearing ANYWHERE in the rest of the file.&lt;BR /&gt;&lt;BR /&gt;My script only changes that one line and only those columns.  You can fix part of it by using "1s/$VAR1/AIR/" and change cat to "head -1".</description>
      <pubDate>Wed, 14 Mar 2007 02:26:03 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/data-manipulation-in-the-file/m-p/5033606#M95075</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2007-03-14T02:26:03Z</dc:date>
    </item>
  </channel>
</rss>

