<?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: string manipulation inquiry in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/string-manipulation-inquiry/m-p/3639827#M105124</link>
    <description>Simple awk format as,&lt;BR /&gt;&lt;BR /&gt;export Var=$(awk -F, '/PRODUCT,.*HD20/ { print $2; }' $FILE)&lt;BR /&gt;&lt;BR /&gt;Or else you can directly check it as,&lt;BR /&gt;&lt;BR /&gt;if [ $(awk -F, '/PRODUCT,.*HD20/ { print $2; }') = "" ]&lt;BR /&gt;do&lt;BR /&gt; # Nothing there&lt;BR /&gt;else&lt;BR /&gt;  # There is HD20&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;hth.&lt;BR /&gt;</description>
    <pubDate>Mon, 03 Oct 2005 01:55:46 GMT</pubDate>
    <dc:creator>Muthukumar_5</dc:creator>
    <dc:date>2005-10-03T01:55:46Z</dc:date>
    <item>
      <title>string manipulation inquiry</title>
      <link>https://community.hpe.com/t5/operating-system-linux/string-manipulation-inquiry/m-p/3639820#M105117</link>
      <description>Dear Gurus,&lt;BR /&gt;&lt;BR /&gt;I have a file with the following contents,&lt;BR /&gt;&lt;BR /&gt;...&lt;BR /&gt;...&lt;BR /&gt;PRODUCT,XXXYYYZZZ_75_HD20&lt;BR /&gt;...&lt;BR /&gt;...&lt;BR /&gt;&lt;BR /&gt;i have used awk to get the content of the product field (which is XXXYYYZZZ_75_HD20).&lt;BR /&gt;&lt;BR /&gt;export Var=$(awk -F "," '/PRODUCT/ {print $2}' $FILE)&lt;BR /&gt;&lt;BR /&gt;After getting the product content, i have to manipulate the result by truncating the "_HD20"&lt;BR /&gt;which is a contant in some devices (others dont have). &lt;BR /&gt;&lt;BR /&gt;I need to write a script in which it has to test if the content of the product has the "_HD20" strings and eventually put the product in a variable and compare it to other file for matching.&lt;BR /&gt;&lt;BR /&gt;Maximum points for all correct answers!</description>
      <pubDate>Sun, 02 Oct 2005 21:59:34 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/string-manipulation-inquiry/m-p/3639820#M105117</guid>
      <dc:creator>Pando</dc:creator>
      <dc:date>2005-10-02T21:59:34Z</dc:date>
    </item>
    <item>
      <title>Re: string manipulation inquiry</title>
      <link>https://community.hpe.com/t5/operating-system-linux/string-manipulation-inquiry/m-p/3639821#M105118</link>
      <description>var='PRODUCT,XXXYYYZZZ_75_HD20'&lt;BR /&gt;var1=${var1##*,}&lt;BR /&gt;check=`awk -F "_" '{print $3}'&lt;BR /&gt;if [[ ${check} = "HD20" ]]&lt;BR /&gt;then&lt;BR /&gt;your_code here&lt;BR /&gt;else&lt;BR /&gt;some more code&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Sun, 02 Oct 2005 23:11:50 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/string-manipulation-inquiry/m-p/3639821#M105118</guid>
      <dc:creator>RAC_1</dc:creator>
      <dc:date>2005-10-02T23:11:50Z</dc:date>
    </item>
    <item>
      <title>Re: string manipulation inquiry</title>
      <link>https://community.hpe.com/t5/operating-system-linux/string-manipulation-inquiry/m-p/3639822#M105119</link>
      <description>how about just doing the substring twice&lt;BR /&gt;&lt;BR /&gt;var='PRODUCT,XXXYYYZZZ_75_HD20'&lt;BR /&gt;var1=${var##*,}&lt;BR /&gt;check=${var1##*_}&lt;BR /&gt;if [[ ${check} = "HD20" ]]&lt;BR /&gt;</description>
      <pubDate>Sun, 02 Oct 2005 23:27:42 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/string-manipulation-inquiry/m-p/3639822#M105119</guid>
      <dc:creator>curt larson_1</dc:creator>
      <dc:date>2005-10-02T23:27:42Z</dc:date>
    </item>
    <item>
      <title>Re: string manipulation inquiry</title>
      <link>https://community.hpe.com/t5/operating-system-linux/string-manipulation-inquiry/m-p/3639823#M105120</link>
      <description>and if you just want to use awk&lt;BR /&gt;cat yourFile |&lt;BR /&gt;awk -f "," '&lt;BR /&gt;/PRODUCT/ {&lt;BR /&gt;split($2,a,"_");&lt;BR /&gt;print $2, a[1] a[2], a[3];&lt;BR /&gt;}' |&lt;BR /&gt;while read a b c&lt;BR /&gt;print $a $b $c&lt;BR /&gt;done</description>
      <pubDate>Sun, 02 Oct 2005 23:38:29 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/string-manipulation-inquiry/m-p/3639823#M105120</guid>
      <dc:creator>curt larson_1</dc:creator>
      <dc:date>2005-10-02T23:38:29Z</dc:date>
    </item>
    <item>
      <title>Re: string manipulation inquiry</title>
      <link>https://community.hpe.com/t5/operating-system-linux/string-manipulation-inquiry/m-p/3639824#M105121</link>
      <description>to truncate&lt;BR /&gt;&lt;BR /&gt;var='PRODUCT,XXXYYYZZZ_75_HD20'&lt;BR /&gt;var1=${var##*,}&lt;BR /&gt;check=${var1##*_}  #remove everything from the begining of the line to the last underscore "_". will be HD20 if it is there&lt;BR /&gt;rest=${var1%_*)    #remove everything from the end of the line up and including the "_".  will be XXXYYYZZZ_75 &lt;BR /&gt;</description>
      <pubDate>Sun, 02 Oct 2005 23:43:50 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/string-manipulation-inquiry/m-p/3639824#M105121</guid>
      <dc:creator>curt larson_1</dc:creator>
      <dc:date>2005-10-02T23:43:50Z</dc:date>
    </item>
    <item>
      <title>Re: string manipulation inquiry</title>
      <link>https://community.hpe.com/t5/operating-system-linux/string-manipulation-inquiry/m-p/3639825#M105122</link>
      <description>You can try like,&lt;BR /&gt;&lt;BR /&gt;export Var=$(awk -F, '/PRODUCT/ { if ( $2 ~ /HD20/ ) { print $2 }}' $FILE)&lt;BR /&gt;&lt;BR /&gt;where,&lt;BR /&gt;&lt;BR /&gt;a) awk splits with ","&lt;BR /&gt;b) check's PRODUCT keyword&lt;BR /&gt;c) Prints XXXYYYZZZ_75_HD20 when second field contains HD20 keyword&lt;BR /&gt;&lt;BR /&gt;else Var will empty.&lt;BR /&gt;&lt;BR /&gt;You can check like,&lt;BR /&gt;&lt;BR /&gt;if [ "$var" = "" ]&lt;BR /&gt;then&lt;BR /&gt;  # var is empty&lt;BR /&gt;else&lt;BR /&gt;  # var is with XXXYYYZZZ_75_HD20&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;hth.</description>
      <pubDate>Mon, 03 Oct 2005 01:49:54 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/string-manipulation-inquiry/m-p/3639825#M105122</guid>
      <dc:creator>Muthukumar_5</dc:creator>
      <dc:date>2005-10-03T01:49:54Z</dc:date>
    </item>
    <item>
      <title>Re: string manipulation inquiry</title>
      <link>https://community.hpe.com/t5/operating-system-linux/string-manipulation-inquiry/m-p/3639826#M105123</link>
      <description>You can very well use perl also as,&lt;BR /&gt;&lt;BR /&gt;export product=$(perl -ne 'split /,/; print $_[1] if /PRODUCT,.*HD20/' $FILE)&lt;BR /&gt;&lt;BR /&gt;with check code.&lt;BR /&gt;&lt;BR /&gt;hth.</description>
      <pubDate>Mon, 03 Oct 2005 01:52:54 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/string-manipulation-inquiry/m-p/3639826#M105123</guid>
      <dc:creator>Muthukumar_5</dc:creator>
      <dc:date>2005-10-03T01:52:54Z</dc:date>
    </item>
    <item>
      <title>Re: string manipulation inquiry</title>
      <link>https://community.hpe.com/t5/operating-system-linux/string-manipulation-inquiry/m-p/3639827#M105124</link>
      <description>Simple awk format as,&lt;BR /&gt;&lt;BR /&gt;export Var=$(awk -F, '/PRODUCT,.*HD20/ { print $2; }' $FILE)&lt;BR /&gt;&lt;BR /&gt;Or else you can directly check it as,&lt;BR /&gt;&lt;BR /&gt;if [ $(awk -F, '/PRODUCT,.*HD20/ { print $2; }') = "" ]&lt;BR /&gt;do&lt;BR /&gt; # Nothing there&lt;BR /&gt;else&lt;BR /&gt;  # There is HD20&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;hth.&lt;BR /&gt;</description>
      <pubDate>Mon, 03 Oct 2005 01:55:46 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/string-manipulation-inquiry/m-p/3639827#M105124</guid>
      <dc:creator>Muthukumar_5</dc:creator>
      <dc:date>2005-10-03T01:55:46Z</dc:date>
    </item>
    <item>
      <title>Re: string manipulation inquiry</title>
      <link>https://community.hpe.com/t5/operating-system-linux/string-manipulation-inquiry/m-p/3639828#M105125</link>
      <description>Hi:&lt;BR /&gt;&lt;BR /&gt;Curt Larson's first solution is certainly the fastest and "cheapest".  It leverages shell builtins and therefore runs the faster than deploying 'awk' or 'perl' for the simple task.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Mon, 03 Oct 2005 05:22:31 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/string-manipulation-inquiry/m-p/3639828#M105125</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2005-10-03T05:22:31Z</dc:date>
    </item>
  </channel>
</rss>

