<?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 file content replacement in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/file-content-replacement/m-p/3671671#M102750</link>
    <description>dear gurus,&lt;BR /&gt;&lt;BR /&gt;I would like to ask how can i check if the ENDTIME field inside the file (please see attached file) has the correct format already and not ""   - data? Subsequenty, If the data format is not correct the particular line content needed to be replaced. &lt;BR /&gt;&lt;BR /&gt;I have attached a sample file. From the filename (DEV_1560_DC_1107_210610_S2.TDF), i need to extract the field 4th (1107) and 5th (210610) in the filename and place it in the ENDTIME line as&lt;BR /&gt;&lt;BR /&gt;ENDTIME,20051107-210610&lt;BR /&gt;&lt;BR /&gt;The 2005 is a prefix to the 4th field in the filename.&lt;BR /&gt;&lt;BR /&gt;Maximum points for all correct answers.</description>
    <pubDate>Tue, 15 Nov 2005 02:38:56 GMT</pubDate>
    <dc:creator>Pando</dc:creator>
    <dc:date>2005-11-15T02:38:56Z</dc:date>
    <item>
      <title>file content replacement</title>
      <link>https://community.hpe.com/t5/operating-system-linux/file-content-replacement/m-p/3671671#M102750</link>
      <description>dear gurus,&lt;BR /&gt;&lt;BR /&gt;I would like to ask how can i check if the ENDTIME field inside the file (please see attached file) has the correct format already and not ""   - data? Subsequenty, If the data format is not correct the particular line content needed to be replaced. &lt;BR /&gt;&lt;BR /&gt;I have attached a sample file. From the filename (DEV_1560_DC_1107_210610_S2.TDF), i need to extract the field 4th (1107) and 5th (210610) in the filename and place it in the ENDTIME line as&lt;BR /&gt;&lt;BR /&gt;ENDTIME,20051107-210610&lt;BR /&gt;&lt;BR /&gt;The 2005 is a prefix to the 4th field in the filename.&lt;BR /&gt;&lt;BR /&gt;Maximum points for all correct answers.</description>
      <pubDate>Tue, 15 Nov 2005 02:38:56 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/file-content-replacement/m-p/3671671#M102750</guid>
      <dc:creator>Pando</dc:creator>
      <dc:date>2005-11-15T02:38:56Z</dc:date>
    </item>
    <item>
      <title>Re: file content replacement</title>
      <link>https://community.hpe.com/t5/operating-system-linux/file-content-replacement/m-p/3671672#M102751</link>
      <description>Using awk as,&lt;BR /&gt;&lt;BR /&gt;#awk 'BEGIN{split(ARGV[1],a,"_");}{if ( $0 ~ /ENDTIME/ ) {print "ENDTIME,2005"a[4]"-"a[5]; } else { print;}}' DEV_1560_DC_1107_210610_S2.TDF &amp;gt; test.TDF&lt;BR /&gt;# mv test.TDF DEV_1560_DC_1107_210610_S2.TDF&lt;BR /&gt;&lt;BR /&gt;hth.</description>
      <pubDate>Tue, 15 Nov 2005 02:54:47 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/file-content-replacement/m-p/3671672#M102751</guid>
      <dc:creator>Muthukumar_5</dc:creator>
      <dc:date>2005-11-15T02:54:47Z</dc:date>
    </item>
    <item>
      <title>Re: file content replacement</title>
      <link>https://community.hpe.com/t5/operating-system-linux/file-content-replacement/m-p/3671673#M102752</link>
      <description>Is 2005 - current year? If so,&lt;BR /&gt;&lt;BR /&gt;With scripting:&lt;BR /&gt;&lt;BR /&gt;#!/bin/ksh&lt;BR /&gt;# test.ksh&lt;BR /&gt;&lt;BR /&gt;FILE=DEV_1560_DC_1107_210610_S2.TDF&lt;BR /&gt;PATTERN=$(echo "`date +'%Y'``echo $FILE | awk -F_ '{ print $4"-"$5 }'`")&lt;BR /&gt;&lt;BR /&gt;sed -e "s/^ENDTIME,.*/ENDTIME,$PATTERN/g" $FILE &amp;gt; test.TDF&lt;BR /&gt;mv test.TDF &amp;gt; $FILE&lt;BR /&gt;&lt;BR /&gt;# exit&lt;BR /&gt;exit 0&lt;BR /&gt;&lt;BR /&gt;hth.</description>
      <pubDate>Tue, 15 Nov 2005 03:12:44 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/file-content-replacement/m-p/3671673#M102752</guid>
      <dc:creator>Muthukumar_5</dc:creator>
      <dc:date>2005-11-15T03:12:44Z</dc:date>
    </item>
    <item>
      <title>Re: file content replacement</title>
      <link>https://community.hpe.com/t5/operating-system-linux/file-content-replacement/m-p/3671674#M102753</link>
      <description>You can use perl as,&lt;BR /&gt;&lt;BR /&gt;# perl -ni -e 'BEGIN{ $p1="-";($p0,$p2)=(split /_/,$ARGV[0])[3,4];}{ if (/ENDTIME/){print "ENDTIME,$p0$p1$p2\n"}else {print;} }' &lt;FILENAME&gt;&lt;BR /&gt;&lt;BR /&gt;It will update the contents also.&lt;BR /&gt;&lt;BR /&gt;hth.&lt;/FILENAME&gt;</description>
      <pubDate>Tue, 15 Nov 2005 03:23:13 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/file-content-replacement/m-p/3671674#M102753</guid>
      <dc:creator>Muthukumar_5</dc:creator>
      <dc:date>2005-11-15T03:23:13Z</dc:date>
    </item>
    <item>
      <title>Re: file content replacement</title>
      <link>https://community.hpe.com/t5/operating-system-linux/file-content-replacement/m-p/3671675#M102754</link>
      <description>Hi Fernando,&lt;BR /&gt;&lt;BR /&gt;if I get it correct - there is a bit of testing to be done.&lt;BR /&gt;Attached, please find an approach using standard commands; the script should be able to handle all files listed in the directory which you have to specify (FULL_PATH_TO_FILES).&lt;BR /&gt; However, I would recommend that you, if you at all dare to uncomment the mv command line(!), enter a different destination path, in order not to overwrite your original files.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;regards,&lt;BR /&gt;John K.</description>
      <pubDate>Tue, 15 Nov 2005 03:55:41 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/file-content-replacement/m-p/3671675#M102754</guid>
      <dc:creator>john korterman</dc:creator>
      <dc:date>2005-11-15T03:55:41Z</dc:date>
    </item>
  </channel>
</rss>

