<?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: sed command usage in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/sed-command-usage/m-p/3922361#M97208</link>
    <description>Hi,&lt;BR /&gt;and welcome to the forums.&lt;BR /&gt;&lt;BR /&gt;please see:&lt;BR /&gt;&lt;A href="http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=1088879" target="_blank"&gt;http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=1088879&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;sed '1 s/./a/100' a.lis &amp;gt; b.lis&lt;BR /&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.</description>
    <pubDate>Mon, 08 Jan 2007 08:06:27 GMT</pubDate>
    <dc:creator>Peter Godron</dc:creator>
    <dc:date>2007-01-08T08:06:27Z</dc:date>
    <item>
      <title>sed command usage</title>
      <link>https://community.hpe.com/t5/operating-system-linux/sed-command-usage/m-p/3922360#M97207</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;I would like to insert a word or a character in a file exactly at 100th position or column in the first line.  100th position may also be a blank space.&lt;BR /&gt;&lt;BR /&gt;Thanks in advance.</description>
      <pubDate>Mon, 08 Jan 2007 07:51:32 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/sed-command-usage/m-p/3922360#M97207</guid>
      <dc:creator>vthiru</dc:creator>
      <dc:date>2007-01-08T07:51:32Z</dc:date>
    </item>
    <item>
      <title>Re: sed command usage</title>
      <link>https://community.hpe.com/t5/operating-system-linux/sed-command-usage/m-p/3922361#M97208</link>
      <description>Hi,&lt;BR /&gt;and welcome to the forums.&lt;BR /&gt;&lt;BR /&gt;please see:&lt;BR /&gt;&lt;A href="http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=1088879" target="_blank"&gt;http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=1088879&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;sed '1 s/./a/100' a.lis &amp;gt; b.lis&lt;BR /&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.</description>
      <pubDate>Mon, 08 Jan 2007 08:06:27 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/sed-command-usage/m-p/3922361#M97208</guid>
      <dc:creator>Peter Godron</dc:creator>
      <dc:date>2007-01-08T08:06:27Z</dc:date>
    </item>
    <item>
      <title>Re: sed command usage</title>
      <link>https://community.hpe.com/t5/operating-system-linux/sed-command-usage/m-p/3922362#M97209</link>
      <description>Hi:&lt;BR /&gt;&lt;BR /&gt;# perl -pe 'if ($.==1) {s/(.{100})(.*)/$1WORD$2/}' file&lt;BR /&gt;&lt;BR /&gt;If you want to update the file "in-place" and preserve a backup copy as "file.old" do:&lt;BR /&gt;&lt;BR /&gt;# perl -pi.old -e 'if ($.==1) {s/(.{100})(.*)/$1WORD$2/}' file&lt;BR /&gt;&lt;BR /&gt;In either case change WORD to be what you want --- a single character or a "word".  Only the first record of the file will be updated.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Mon, 08 Jan 2007 08:12:02 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/sed-command-usage/m-p/3922362#M97209</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2007-01-08T08:12:02Z</dc:date>
    </item>
    <item>
      <title>Re: sed command usage</title>
      <link>https://community.hpe.com/t5/operating-system-linux/sed-command-usage/m-p/3922363#M97210</link>
      <description>Thanks Peter.&lt;BR /&gt;&lt;BR /&gt;But the command doesn't work if 100th column is a blank space or if the file contains only few characters.  Please let me know how to include a character or a word at 100th column.&lt;BR /&gt;&lt;BR /&gt;Thanks in advance.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 08 Jan 2007 08:12:46 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/sed-command-usage/m-p/3922363#M97210</guid>
      <dc:creator>vthiru</dc:creator>
      <dc:date>2007-01-08T08:12:46Z</dc:date>
    </item>
    <item>
      <title>Re: sed command usage</title>
      <link>https://community.hpe.com/t5/operating-system-linux/sed-command-usage/m-p/3922364#M97211</link>
      <description>Hi,&lt;BR /&gt;thanks for the feedback.&lt;BR /&gt;But the command doesn't work if 100th column is a blank space or if the file contains only few characters. Please let me know how to include a character or a word at 100th column.&lt;BR /&gt;&lt;BR /&gt;I have tested my solution on a short datafile, with the first line being 10 chars long, and the space is not problem. &lt;BR /&gt;&lt;BR /&gt;1234 67890 becomes 1234a67890 with sed '1 s/./a/5'&lt;BR /&gt;&lt;BR /&gt;However it now appears your first line may be shorter than 100 characters (Is this correct ?) and what you want to happen in this case is to buffer the line up to 100 characters and then add your data.&lt;BR /&gt;&lt;BR /&gt;Can you please confirm this and any other 'additional' requirement.</description>
      <pubDate>Mon, 08 Jan 2007 08:21:09 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/sed-command-usage/m-p/3922364#M97211</guid>
      <dc:creator>Peter Godron</dc:creator>
      <dc:date>2007-01-08T08:21:09Z</dc:date>
    </item>
    <item>
      <title>Re: sed command usage</title>
      <link>https://community.hpe.com/t5/operating-system-linux/sed-command-usage/m-p/3922365#M97212</link>
      <description>&lt;!--!*#--&gt;Hi (again):&lt;BR /&gt;&lt;BR /&gt;&amp;gt; But the command doesn't work if 100th column is a blank space or if the file contains only few characters. Please let me know how to include a character or a word at 100th column.&lt;BR /&gt;&lt;BR /&gt;OK, then perhaps:&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/perl -ni.old&lt;BR /&gt;if ( $. == 1 ) {&lt;BR /&gt;    if ( length($_) &amp;lt; 100 ) {&lt;BR /&gt;        chomp;&lt;BR /&gt;        printf "%-100s%s\n", $_, "WORD";&lt;BR /&gt;    }&lt;BR /&gt;    else {&lt;BR /&gt;        s/(.{100})(.*)/$1WORD$2/;&lt;BR /&gt;        print;&lt;BR /&gt;    }&lt;BR /&gt;    next;&lt;BR /&gt;}&lt;BR /&gt;print;&lt;BR /&gt;&lt;BR /&gt;...Once again, change WORD to whatever you want (in both places).  This will update your file in-place and keep a backup as ("*.old").&lt;BR /&gt;&lt;BR /&gt;Run as:&lt;BR /&gt;&lt;BR /&gt;# .filter file&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Mon, 08 Jan 2007 08:59:27 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/sed-command-usage/m-p/3922365#M97212</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2007-01-08T08:59:27Z</dc:date>
    </item>
    <item>
      <title>Re: sed command usage</title>
      <link>https://community.hpe.com/t5/operating-system-linux/sed-command-usage/m-p/3922366#M97213</link>
      <description>Thanks Peter and James. It worked!!</description>
      <pubDate>Sat, 13 Jan 2007 06:13:48 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/sed-command-usage/m-p/3922366#M97213</guid>
      <dc:creator>vthiru</dc:creator>
      <dc:date>2007-01-13T06:13:48Z</dc:date>
    </item>
    <item>
      <title>Re: sed command usage</title>
      <link>https://community.hpe.com/t5/operating-system-linux/sed-command-usage/m-p/3922367#M97214</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;since you are new to this forum - welcome here! - I wnat to put your attention to the points system:&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://forums1.itrc.hp.com/service/forums/helptips.do?#28" target="_blank"&gt;http://forums1.itrc.hp.com/service/forums/helptips.do?#28&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;mfG Peter</description>
      <pubDate>Sat, 13 Jan 2007 07:31:43 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/sed-command-usage/m-p/3922367#M97214</guid>
      <dc:creator>Peter Nikitka</dc:creator>
      <dc:date>2007-01-13T07:31:43Z</dc:date>
    </item>
  </channel>
</rss>

