<?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: shell script in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/shell-script/m-p/3825607#M100458</link>
    <description>cut -d":" -f 2&lt;BR /&gt;&lt;BR /&gt;you'll still have a ';' at the end but that's removed quickly with sed or something similar.</description>
    <pubDate>Wed, 19 Jul 2006 03:32:04 GMT</pubDate>
    <dc:creator>dirk dierickx</dc:creator>
    <dc:date>2006-07-19T03:32:04Z</dc:date>
    <item>
      <title>shell script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/shell-script/m-p/3825601#M100452</link>
      <description>Hi,&lt;BR /&gt;I have a string like &lt;BR /&gt;"ax-a1: xxx@xxx.com yyy@yyy.com zzz@zzz.com;&lt;BR /&gt; ax-a2: aaa@aaa.com bbb@bbb.com ccc@ccc.com;"&lt;BR /&gt;&lt;BR /&gt;I need to extract the mailid seperated by a space for any given user like ax-a1. &lt;BR /&gt;&lt;BR /&gt;I have tried to use &lt;BR /&gt;Test=`grep a1-ax mailids.txt`&lt;BR /&gt;echo $Test | awk '{print substr($0,":",index($0,";"))}'&lt;BR /&gt;&lt;BR /&gt;but it doesn't seem to work. Can you please suggest??&lt;BR /&gt;&lt;BR /&gt;TIA&lt;BR /&gt;</description>
      <pubDate>Tue, 18 Jul 2006 10:45:46 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/shell-script/m-p/3825601#M100452</guid>
      <dc:creator>mougli</dc:creator>
      <dc:date>2006-07-18T10:45:46Z</dc:date>
    </item>
    <item>
      <title>Re: shell script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/shell-script/m-p/3825602#M100453</link>
      <description>&lt;BR /&gt;Hmm,&lt;BR /&gt;&lt;BR /&gt;The second argument to substr is an offset numner, and you passed it a piece of string.&lt;BR /&gt;That's not goign to work.&lt;BR /&gt;&lt;BR /&gt;Please explain a little more clearly what you expact for output and where the input comes from.&lt;BR /&gt;- A single long string with multiple usernames + email?&lt;BR /&gt;- When ax-a1 is select, which are we supposed to return:  xxx@xxx.com, or all of "xxx@xxx.com yyy@yyy.com zzz@zzz.com"?&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;You may readily find a solution by using a regexpr for field seperator. Check out the following example:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;$ cat x&lt;BR /&gt;ax-a1: xxx@xxx.com yyy@yyy.com zzz@zzz.com; ax-a2: aaa@aaa.com bbb@bbb.com ccc@ccc.com;&lt;BR /&gt;$ awk -F'[:; ]+' '{print $3}' x&lt;BR /&gt;yyy@yyy.com&lt;BR /&gt;$ awk -F'[:;]' '{print $3}' x&lt;BR /&gt; ax-a2&lt;BR /&gt;$ awk -F'[:;]' '{print $2}' x&lt;BR /&gt; xxx@xxx.com yyy@yyy.com zzz@zzz.com&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Hope this helps some...&lt;BR /&gt;Hein.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 18 Jul 2006 11:04:28 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/shell-script/m-p/3825602#M100453</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2006-07-18T11:04:28Z</dc:date>
    </item>
    <item>
      <title>Re: shell script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/shell-script/m-p/3825603#M100454</link>
      <description>&lt;!--!*#--&gt;Hi,&lt;BR /&gt;&lt;BR /&gt;if your string has an entry&lt;BR /&gt;ax-a1&lt;BR /&gt;und you grep for&lt;BR /&gt;a1-ax&lt;BR /&gt;you won't get results :-)&lt;BR /&gt;&lt;BR /&gt;This will give you the second field stripped by the last character, which is ";" in your case:&lt;BR /&gt;&lt;BR /&gt;awk -F: -v user=ax-a1 '$1 == user {print substr($2,1,length($2)-1)}' mailids.txt&lt;BR /&gt;&lt;BR /&gt;mfG Peter</description>
      <pubDate>Tue, 18 Jul 2006 11:05:56 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/shell-script/m-p/3825603#M100454</guid>
      <dc:creator>Peter Nikitka</dc:creator>
      <dc:date>2006-07-18T11:05:56Z</dc:date>
    </item>
    <item>
      <title>Re: shell script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/shell-script/m-p/3825604#M100455</link>
      <description>Buildin up on the external passed usename you could 'walk' the field in steps of 2 looking for a username match.&lt;BR /&gt;Note, I had to strip spaces from the username for it to match easily:&lt;BR /&gt;&lt;BR /&gt;$awk -F'[:;]' -v user=ax-a2 '{i=0; while (i++&lt;NF&gt;&lt;/NF&gt;&lt;BR /&gt;aaa@aaa.com bbb@bbb.com ccc@ccc.com&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Or you could have 'fields' be user:email by using ';' as FS (field seperator) and then splitting on ":" to look at the parts:&lt;BR /&gt;&lt;BR /&gt;$ awk -F\; -v user=ax-a1 '{i=0; while (i++&lt;NF&gt;&lt;/NF&gt; xxx@xxx.com yyy@yyy.com zzz@zzz.com&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Hein.&lt;BR /&gt;</description>
      <pubDate>Tue, 18 Jul 2006 12:42:03 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/shell-script/m-p/3825604#M100455</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2006-07-18T12:42:03Z</dc:date>
    </item>
    <item>
      <title>Re: shell script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/shell-script/m-p/3825605#M100456</link>
      <description>Hi:&lt;BR /&gt;&lt;BR /&gt;How about:&lt;BR /&gt;&lt;BR /&gt;# STR="ax-a1: xxx@xxx.com yyy@yyy.com zzz@zzz.com;ax-a2: aaa@aaa.com bbb@bbb.com ccc@ccc.com;"&lt;BR /&gt;&lt;BR /&gt;# echo ${STR} | perl -nle 'BEGIN{$u=shift};print $1 if m/$u:(.+?);/' ax-a1&lt;BR /&gt;&lt;BR /&gt;...would return:&lt;BR /&gt;&lt;BR /&gt; xxx@xxx.com yyy@yyy.com zzz@zzz.com&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Tue, 18 Jul 2006 13:17:29 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/shell-script/m-p/3825605#M100456</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2006-07-18T13:17:29Z</dc:date>
    </item>
    <item>
      <title>Re: shell script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/shell-script/m-p/3825606#M100457</link>
      <description>Here's a way of doing it with sed:&lt;BR /&gt;&lt;BR /&gt;# echo $Test | sed -n 's/\(.*\): \(.*\);/\2/p'&lt;BR /&gt;&lt;BR /&gt;...and with awk&lt;BR /&gt;&lt;BR /&gt;echo $Test | awk -F": " '{print z[split($2,z,";")-1]}'</description>
      <pubDate>Tue, 18 Jul 2006 13:34:03 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/shell-script/m-p/3825606#M100457</guid>
      <dc:creator>Sandman!</dc:creator>
      <dc:date>2006-07-18T13:34:03Z</dc:date>
    </item>
    <item>
      <title>Re: shell script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/shell-script/m-p/3825607#M100458</link>
      <description>cut -d":" -f 2&lt;BR /&gt;&lt;BR /&gt;you'll still have a ';' at the end but that's removed quickly with sed or something similar.</description>
      <pubDate>Wed, 19 Jul 2006 03:32:04 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/shell-script/m-p/3825607#M100458</guid>
      <dc:creator>dirk dierickx</dc:creator>
      <dc:date>2006-07-19T03:32:04Z</dc:date>
    </item>
    <item>
      <title>Re: shell script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/shell-script/m-p/3825608#M100459</link>
      <description>Thanks everyone. Got it working now.</description>
      <pubDate>Wed, 19 Jul 2006 10:16:53 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/shell-script/m-p/3825608#M100459</guid>
      <dc:creator>mougli</dc:creator>
      <dc:date>2006-07-19T10:16:53Z</dc:date>
    </item>
  </channel>
</rss>

