<?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: script to add variable in one line in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/script-to-add-variable-in-one-line/m-p/4761455#M641418</link>
    <description>&lt;!--!*#--&gt;&amp;gt; echo CL_GRP&lt;BR /&gt;&lt;BR /&gt;Do you mean?: echo $CL_GRP&lt;BR /&gt;&lt;BR /&gt;&amp;gt; [...] the method above seems to always&lt;BR /&gt;&amp;gt; generate one empty space.&lt;BR /&gt;&lt;BR /&gt;Are you complaining about the space at the&lt;BR /&gt;beginning of CL_GRP?  If so, then, as usual,&lt;BR /&gt;many things are possible.  For example, one&lt;BR /&gt;could use "sed" to remove a leading space:&lt;BR /&gt;&lt;BR /&gt;echo $CL_GRP | sed -e 's/^ //'&lt;BR /&gt;&lt;BR /&gt;Or, one could avoid putting the space in at&lt;BR /&gt;the beginning:&lt;BR /&gt;&lt;BR /&gt;first=''&lt;BR /&gt;for i in $CL&lt;BR /&gt;do&lt;BR /&gt;    if [ -z $first ]; then&lt;BR /&gt;        CL_GRP="$i $ID"&lt;BR /&gt;        first='no'&lt;BR /&gt;    else&lt;BR /&gt;        CL_GRP="${CL_GRP} $i $ID"&lt;BR /&gt;    fi&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;Or (saving a variable):&lt;BR /&gt;&lt;BR /&gt;CL_GRP=''&lt;BR /&gt;for i in $CL&lt;BR /&gt;do&lt;BR /&gt;    if [ -z $CL_GRP ]; then&lt;BR /&gt;        CL_GRP="$i $ID"&lt;BR /&gt;    else&lt;BR /&gt;        CL_GRP="${CL_GRP} $i $ID"&lt;BR /&gt;    fi&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;(So, people don't learn basic computer&lt;BR /&gt;programming nowadays?)</description>
    <pubDate>Fri, 04 Mar 2011 15:32:39 GMT</pubDate>
    <dc:creator>Steven Schweda</dc:creator>
    <dc:date>2011-03-04T15:32:39Z</dc:date>
    <item>
      <title>script to add variable in one line</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-to-add-variable-in-one-line/m-p/4761454#M641417</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;I have script with the following:&lt;BR /&gt;CL="ABC:BCD:CDE"&lt;BR /&gt;ID=1&lt;BR /&gt;IFS=:&lt;BR /&gt;&lt;BR /&gt;for i in $CL&lt;BR /&gt;do&lt;BR /&gt;CL_GRP="${CL_GRP} $i $ID"&lt;BR /&gt;done&lt;BR /&gt;echo CL_GRP&lt;BR /&gt;&lt;BR /&gt;The output should be&lt;BR /&gt;'ABC' 1 'BCD' 1 'CDE' 1&lt;BR /&gt;&lt;BR /&gt;but the problem is how can I have the ' sign and the method above seems to always generate one empty space.</description>
      <pubDate>Fri, 04 Mar 2011 14:48:16 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-to-add-variable-in-one-line/m-p/4761454#M641417</guid>
      <dc:creator>kholikt</dc:creator>
      <dc:date>2011-03-04T14:48:16Z</dc:date>
    </item>
    <item>
      <title>Re: script to add variable in one line</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-to-add-variable-in-one-line/m-p/4761455#M641418</link>
      <description>&lt;!--!*#--&gt;&amp;gt; echo CL_GRP&lt;BR /&gt;&lt;BR /&gt;Do you mean?: echo $CL_GRP&lt;BR /&gt;&lt;BR /&gt;&amp;gt; [...] the method above seems to always&lt;BR /&gt;&amp;gt; generate one empty space.&lt;BR /&gt;&lt;BR /&gt;Are you complaining about the space at the&lt;BR /&gt;beginning of CL_GRP?  If so, then, as usual,&lt;BR /&gt;many things are possible.  For example, one&lt;BR /&gt;could use "sed" to remove a leading space:&lt;BR /&gt;&lt;BR /&gt;echo $CL_GRP | sed -e 's/^ //'&lt;BR /&gt;&lt;BR /&gt;Or, one could avoid putting the space in at&lt;BR /&gt;the beginning:&lt;BR /&gt;&lt;BR /&gt;first=''&lt;BR /&gt;for i in $CL&lt;BR /&gt;do&lt;BR /&gt;    if [ -z $first ]; then&lt;BR /&gt;        CL_GRP="$i $ID"&lt;BR /&gt;        first='no'&lt;BR /&gt;    else&lt;BR /&gt;        CL_GRP="${CL_GRP} $i $ID"&lt;BR /&gt;    fi&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;Or (saving a variable):&lt;BR /&gt;&lt;BR /&gt;CL_GRP=''&lt;BR /&gt;for i in $CL&lt;BR /&gt;do&lt;BR /&gt;    if [ -z $CL_GRP ]; then&lt;BR /&gt;        CL_GRP="$i $ID"&lt;BR /&gt;    else&lt;BR /&gt;        CL_GRP="${CL_GRP} $i $ID"&lt;BR /&gt;    fi&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;(So, people don't learn basic computer&lt;BR /&gt;programming nowadays?)</description>
      <pubDate>Fri, 04 Mar 2011 15:32:39 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-to-add-variable-in-one-line/m-p/4761455#M641418</guid>
      <dc:creator>Steven Schweda</dc:creator>
      <dc:date>2011-03-04T15:32:39Z</dc:date>
    </item>
    <item>
      <title>Re: script to add variable in one line</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-to-add-variable-in-one-line/m-p/4761456#M641419</link>
      <description>Is there anyway that I can add ' to each CL&lt;BR /&gt;&lt;BR /&gt;for example 'ABC' 'BCD' 'CDE'&lt;BR /&gt;&lt;BR /&gt;instead of ABC BCD CDE</description>
      <pubDate>Fri, 04 Mar 2011 15:59:02 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-to-add-variable-in-one-line/m-p/4761456#M641419</guid>
      <dc:creator>kholikt</dc:creator>
      <dc:date>2011-03-04T15:59:02Z</dc:date>
    </item>
    <item>
      <title>Re: script to add variable in one line</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-to-add-variable-in-one-line/m-p/4761457#M641420</link>
      <description>&lt;!--!*#--&gt;&amp;gt; Is there anyway that I can add ' to each CL&lt;BR /&gt;&lt;BR /&gt;What did you try?&lt;BR /&gt;&lt;BR /&gt;      CL_GRP="'$i' $ID"&lt;BR /&gt;&lt;BR /&gt;(and so on)?</description>
      <pubDate>Fri, 04 Mar 2011 16:04:28 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-to-add-variable-in-one-line/m-p/4761457#M641420</guid>
      <dc:creator>Steven Schweda</dc:creator>
      <dc:date>2011-03-04T16:04:28Z</dc:date>
    </item>
    <item>
      <title>Re: script to add variable in one line</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-to-add-variable-in-one-line/m-p/4761458#M641421</link>
      <description>I have tried&lt;BR /&gt;&lt;BR /&gt;CL="${'CL'} $i"&lt;BR /&gt;&lt;BR /&gt;but it doesn't return as 'ABC''BCD' 'CDE'</description>
      <pubDate>Fri, 04 Mar 2011 16:11:47 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-to-add-variable-in-one-line/m-p/4761458#M641421</guid>
      <dc:creator>kholikt</dc:creator>
      <dc:date>2011-03-04T16:11:47Z</dc:date>
    </item>
    <item>
      <title>Re: script to add variable in one line</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-to-add-variable-in-one-line/m-p/4761459#M641422</link>
      <description>&lt;!--!*#--&gt;&amp;gt; I have tried&lt;BR /&gt;&amp;gt; &lt;BR /&gt;&amp;gt; CL="${'CL'} $i"&lt;BR /&gt;&amp;gt; &lt;BR /&gt;&amp;gt; but it doesn't return as 'ABC''BCD' 'CDE'&lt;BR /&gt;&lt;BR /&gt;Yeah.  I can see why.  Can you?  Did you try&lt;BR /&gt;what I suggested?&lt;BR /&gt;&lt;BR /&gt;      ${'CL'}&lt;BR /&gt;&lt;BR /&gt;Really?  Where do you want the ' characters?&lt;BR /&gt;Around the old stuff (CL) or around the new&lt;BR /&gt;stuff (i)?&lt;BR /&gt;&lt;BR /&gt;Inside the braces?  ${CL} makes sense to me.&lt;BR /&gt;'${CL}' makes sense to me.  ${'CL'} makes no&lt;BR /&gt;sense to me.  (Or to the shell?)</description>
      <pubDate>Fri, 04 Mar 2011 16:23:40 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-to-add-variable-in-one-line/m-p/4761459#M641422</guid>
      <dc:creator>Steven Schweda</dc:creator>
      <dc:date>2011-03-04T16:23:40Z</dc:date>
    </item>
    <item>
      <title>Re: script to add variable in one line</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-to-add-variable-in-one-line/m-p/4761460#M641423</link>
      <description>&lt;!--!*#--&gt;If using ksh or posix-shell, you can also clean-up your extra space by using &lt;BR /&gt;&lt;BR /&gt;${VARIABLE%% } to trim trailing spaces.&lt;BR /&gt;&lt;BR /&gt;So your script would become:&lt;BR /&gt;&lt;BR /&gt;for i in $CL&lt;BR /&gt; do&lt;BR /&gt; CL_GRP="${CL_GRP%% } $i $ID"&lt;BR /&gt;done&lt;BR /&gt;echo "CL_GRP=\"${CL_GRP}\""&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 06 Jun 2011 14:58:00 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-to-add-variable-in-one-line/m-p/4761460#M641423</guid>
      <dc:creator>Joseph Steinhauser</dc:creator>
      <dc:date>2011-06-06T14:58:00Z</dc:date>
    </item>
  </channel>
</rss>

