<?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: filename field extraction in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/filename-field-extraction/m-p/4941595#M102809</link>
    <description>I know the thread is closed and I am not fishing for points any way so.&lt;BR /&gt;&lt;BR /&gt;My suggestion in this case would be to use awk, as Clay did but instead of counting fields I would just use $NF-2 and $NF-1 sense the portions of the file names you want are always going to be 2nd and 3rd from the last.&lt;BR /&gt;&lt;BR /&gt;Might make for a simpler read in the script if you ever have to troubleshoot it.&lt;BR /&gt;&lt;BR /&gt;Howard &lt;BR /&gt;</description>
    <pubDate>Mon, 21 Nov 2005 10:29:47 GMT</pubDate>
    <dc:creator>Howard Marshall</dc:creator>
    <dc:date>2005-11-21T10:29:47Z</dc:date>
    <item>
      <title>filename field extraction</title>
      <link>https://community.hpe.com/t5/operating-system-linux/filename-field-extraction/m-p/4941591#M102805</link>
      <description>dear gurus,&lt;BR /&gt;&lt;BR /&gt;I have a file with different length and separated by "_". See example of filename below.&lt;BR /&gt;&lt;BR /&gt;aaaa_bb_cc_1111_222222_s1.txt&lt;BR /&gt;xxxx_yy_cc_dd_1111_222222_s2.txt&lt;BR /&gt;&lt;BR /&gt;I would like to seek help on how to extract the 1111 and 222222 from the filenames above and put them in a variable.&lt;BR /&gt;&lt;BR /&gt;Maximum points for all correct replies.</description>
      <pubDate>Thu, 17 Nov 2005 21:33:24 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/filename-field-extraction/m-p/4941591#M102805</guid>
      <dc:creator>Pando</dc:creator>
      <dc:date>2005-11-17T21:33:24Z</dc:date>
    </item>
    <item>
      <title>Re: filename field extraction</title>
      <link>https://community.hpe.com/t5/operating-system-linux/filename-field-extraction/m-p/4941592#M102806</link>
      <description>&lt;BR /&gt;extract()&lt;BR /&gt;{&lt;BR /&gt;  typeset V=${1}&lt;BR /&gt;  shift&lt;BR /&gt;  typeset -i XSTAT=0&lt;BR /&gt;  &lt;BR /&gt;  echo "${V}" | awk -F '_' '{printf("%s_%s\n",$(NF - 2),$(NF - 1))}'&lt;BR /&gt;  XSTAT=${?}&lt;BR /&gt;  return ${XSTAT}&lt;BR /&gt;} # extract&lt;BR /&gt;&lt;BR /&gt;V1="aaaa_bbb_cc_11111_222222_s1.txt"&lt;BR /&gt;XX=$(extract "${V1}")&lt;BR /&gt;echo "XX = ${XX}"&lt;BR /&gt;</description>
      <pubDate>Thu, 17 Nov 2005 22:23:55 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/filename-field-extraction/m-p/4941592#M102806</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2005-11-17T22:23:55Z</dc:date>
    </item>
    <item>
      <title>Re: filename field extraction</title>
      <link>https://community.hpe.com/t5/operating-system-linux/filename-field-extraction/m-p/4941593#M102807</link>
      <description>Hi ACS,&lt;BR /&gt;&lt;BR /&gt;the 1111 and 222222 needs to be in a separate variable. thanks!&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 17 Nov 2005 22:32:25 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/filename-field-extraction/m-p/4941593#M102807</guid>
      <dc:creator>Pando</dc:creator>
      <dc:date>2005-11-17T22:32:25Z</dc:date>
    </item>
    <item>
      <title>Re: filename field extraction</title>
      <link>https://community.hpe.com/t5/operating-system-linux/filename-field-extraction/m-p/4941594#M102808</link>
      <description>Dear ACS,&lt;BR /&gt;&lt;BR /&gt;Thanks for your input!&lt;BR /&gt;Nice job!</description>
      <pubDate>Thu, 17 Nov 2005 22:53:49 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/filename-field-extraction/m-p/4941594#M102808</guid>
      <dc:creator>Pando</dc:creator>
      <dc:date>2005-11-17T22:53:49Z</dc:date>
    </item>
    <item>
      <title>Re: filename field extraction</title>
      <link>https://community.hpe.com/t5/operating-system-linux/filename-field-extraction/m-p/4941595#M102809</link>
      <description>I know the thread is closed and I am not fishing for points any way so.&lt;BR /&gt;&lt;BR /&gt;My suggestion in this case would be to use awk, as Clay did but instead of counting fields I would just use $NF-2 and $NF-1 sense the portions of the file names you want are always going to be 2nd and 3rd from the last.&lt;BR /&gt;&lt;BR /&gt;Might make for a simpler read in the script if you ever have to troubleshoot it.&lt;BR /&gt;&lt;BR /&gt;Howard &lt;BR /&gt;</description>
      <pubDate>Mon, 21 Nov 2005 10:29:47 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/filename-field-extraction/m-p/4941595#M102809</guid>
      <dc:creator>Howard Marshall</dc:creator>
      <dc:date>2005-11-21T10:29:47Z</dc:date>
    </item>
  </channel>
</rss>

