<?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 help for script in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/help-for-script/m-p/4933008#M102353</link>
    <description>i have one file ex.given below&lt;BR /&gt;&lt;BR /&gt;id  Output  Description&lt;BR /&gt;abc  abc123  xxxx&lt;BR /&gt;xyz  dbname  xxx&lt;BR /&gt;123  dbname1  xxx&lt;BR /&gt;&lt;BR /&gt;for given above i want to write scritp to take output correspondign id&lt;BR /&gt;without space &lt;BR /&gt;if abc identified the abc123 output goes to some variablt, i tried but&lt;BR /&gt;its output is coming with spaces</description>
    <pubDate>Wed, 12 Oct 2005 01:58:14 GMT</pubDate>
    <dc:creator>Karthick K S</dc:creator>
    <dc:date>2005-10-12T01:58:14Z</dc:date>
    <item>
      <title>help for script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/help-for-script/m-p/4933008#M102353</link>
      <description>i have one file ex.given below&lt;BR /&gt;&lt;BR /&gt;id  Output  Description&lt;BR /&gt;abc  abc123  xxxx&lt;BR /&gt;xyz  dbname  xxx&lt;BR /&gt;123  dbname1  xxx&lt;BR /&gt;&lt;BR /&gt;for given above i want to write scritp to take output correspondign id&lt;BR /&gt;without space &lt;BR /&gt;if abc identified the abc123 output goes to some variablt, i tried but&lt;BR /&gt;its output is coming with spaces</description>
      <pubDate>Wed, 12 Oct 2005 01:58:14 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/help-for-script/m-p/4933008#M102353</guid>
      <dc:creator>Karthick K S</dc:creator>
      <dc:date>2005-10-12T01:58:14Z</dc:date>
    </item>
    <item>
      <title>Re: help for script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/help-for-script/m-p/4933009#M102354</link>
      <description>Hi, could you explain how did you try to get the output.&lt;BR /&gt;&lt;BR /&gt;awk '$1=="123"{print $2}' your_file_name&lt;BR /&gt;&lt;BR /&gt;will print "dbname1" without any spaces.&lt;BR /&gt;&lt;BR /&gt;if you would like to assign this to a shell variable than something like &lt;BR /&gt;&lt;BR /&gt;myvar=`awk '$1=="123"{print $2}' your_file_name`&lt;BR /&gt;&lt;BR /&gt;will do the job.&lt;BR /&gt;&lt;BR /&gt;hth</description>
      <pubDate>Wed, 12 Oct 2005 02:35:37 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/help-for-script/m-p/4933009#M102354</guid>
      <dc:creator>Orhan Biyiklioglu</dc:creator>
      <dc:date>2005-10-12T02:35:37Z</dc:date>
    </item>
    <item>
      <title>Re: help for script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/help-for-script/m-p/4933010#M102355</link>
      <description>export $rid=abc&lt;BR /&gt;export FILE=/abc/ho/&lt;BR /&gt;&lt;BR /&gt;grep $rid ${FILE}/recv.txt | cut -d "=" -f2&lt;BR /&gt;&lt;BR /&gt;if i use this above one output is coming but with spacec For eg:&lt;BR /&gt;&lt;BR /&gt;output&lt;BR /&gt;" dbname"&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 12 Oct 2005 02:52:14 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/help-for-script/m-p/4933010#M102355</guid>
      <dc:creator>Karthick K S</dc:creator>
      <dc:date>2005-10-12T02:52:14Z</dc:date>
    </item>
    <item>
      <title>Re: help for script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/help-for-script/m-p/4933011#M102356</link>
      <description>Hi,&lt;BR /&gt;It worked for me in this way, no spaces in the output:&lt;BR /&gt;&lt;BR /&gt;(root@server1)[/] export rid=abc&lt;BR /&gt;(root@server1)[/] cat xyz&lt;BR /&gt;abc abc123 xxxx&lt;BR /&gt;xyz dbname xxx&lt;BR /&gt;123 dbname1 xxx&lt;BR /&gt;(root@server1)[/] export FILE=/&lt;BR /&gt;(root@server1)[/] grep $rid ${FILE}xyz | cut -d " " -f2&lt;BR /&gt;abc123&lt;BR /&gt;(root@server1)[/]&lt;BR /&gt;&lt;BR /&gt;Hope that helps.&lt;BR /&gt;Regards,&lt;BR /&gt;</description>
      <pubDate>Wed, 12 Oct 2005 03:06:12 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/help-for-script/m-p/4933011#M102356</guid>
      <dc:creator>Bharat Katkar</dc:creator>
      <dc:date>2005-10-12T03:06:12Z</dc:date>
    </item>
    <item>
      <title>Re: help for script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/help-for-script/m-p/4933012#M102357</link>
      <description>-d option of the cut command specifies the field delimitter. Why do you use cut -d "=" since there is no "=" in your file.&lt;BR /&gt;&lt;BR /&gt;export $rid=abc&lt;BR /&gt;export FILE=/abc/ho/&lt;BR /&gt;&lt;BR /&gt;grep $rid ${FILE}/recv.txt | cut -d " " -f2&lt;BR /&gt;&lt;BR /&gt;should work.&lt;BR /&gt;&lt;BR /&gt;You can also use the awk command instead of the grep and cut commands (only one command invocation)&lt;BR /&gt;&lt;BR /&gt;awk -v rid=$rid '$1==rid{print $2}' ${FILE}/recv.txt</description>
      <pubDate>Wed, 12 Oct 2005 03:15:39 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/help-for-script/m-p/4933012#M102357</guid>
      <dc:creator>Orhan Biyiklioglu</dc:creator>
      <dc:date>2005-10-12T03:15:39Z</dc:date>
    </item>
    <item>
      <title>Re: help for script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/help-for-script/m-p/4933013#M102358</link>
      <description>if i am using cut spaces is coming output &lt;BR /&gt;my o/p should be&lt;BR /&gt;myvar is output of cut command&lt;BR /&gt;&lt;BR /&gt;/dir/$myvar</description>
      <pubDate>Wed, 12 Oct 2005 03:25:08 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/help-for-script/m-p/4933013#M102358</guid>
      <dc:creator>Karthick K S</dc:creator>
      <dc:date>2005-10-12T03:25:08Z</dc:date>
    </item>
    <item>
      <title>Re: help for script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/help-for-script/m-p/4933014#M102359</link>
      <description>Have you tried&lt;BR /&gt;&lt;BR /&gt;export $rid=abc&lt;BR /&gt;export FILE=/abc/ho/&lt;BR /&gt;&lt;BR /&gt;this:&lt;BR /&gt;&lt;BR /&gt;grep $rid ${FILE}/recv.txt | cut -d " " -f2&lt;BR /&gt;&lt;BR /&gt;or this:&lt;BR /&gt;&lt;BR /&gt;awk -v rid=$rid '$1==rid{print $2}' ${FILE}/recv.txt</description>
      <pubDate>Wed, 12 Oct 2005 03:30:00 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/help-for-script/m-p/4933014#M102359</guid>
      <dc:creator>Orhan Biyiklioglu</dc:creator>
      <dc:date>2005-10-12T03:30:00Z</dc:date>
    </item>
    <item>
      <title>Re: help for script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/help-for-script/m-p/4933015#M102360</link>
      <description>Hi Karthick,&lt;BR /&gt;&lt;BR /&gt;Be aware that if in your file you have any string containing "abc", grep will return every line containing "abc", independently of the place where is this chaine in the line.&lt;BR /&gt;&lt;BR /&gt;awk is a good tool to do that, but i find it heavy to use. So i do prefer this kind of approach :&lt;BR /&gt;&lt;BR /&gt;   ID="The string to search"&lt;BR /&gt;   FILE="File to scan"&lt;BR /&gt;&lt;BR /&gt;   OUTPUT=&lt;BR /&gt;   egrep "^$ID +" $FILE | read nop OUTPUT nop&lt;BR /&gt;   if [ -z "$OUTPUT" ]&lt;BR /&gt;   then echo "ID $ID not found"&lt;BR /&gt;   else echo "ID $ID found with OUTPUT $OUTPUT"&lt;BR /&gt;   fi&lt;BR /&gt;&lt;BR /&gt;When U use egrep (enhanced grep) "^" means beginning of line and " +" means one or more spaces. In this manner U are sure to find $ID in the first field, not $ID somewhere on the line.&lt;BR /&gt;&lt;BR /&gt;Hope this will help&lt;BR /&gt;&lt;BR /&gt;Eric&lt;BR /&gt;&lt;BR /&gt;(PBFWME;-)</description>
      <pubDate>Wed, 12 Oct 2005 03:42:11 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/help-for-script/m-p/4933015#M102360</guid>
      <dc:creator>Eric SAUBIGNAC</dc:creator>
      <dc:date>2005-10-12T03:42:11Z</dc:date>
    </item>
    <item>
      <title>Re: help for script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/help-for-script/m-p/4933016#M102361</link>
      <description>Thanks all given a solution</description>
      <pubDate>Wed, 12 Oct 2005 06:16:44 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/help-for-script/m-p/4933016#M102361</guid>
      <dc:creator>Karthick K S</dc:creator>
      <dc:date>2005-10-12T06:16:44Z</dc:date>
    </item>
    <item>
      <title>Re: help for script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/help-for-script/m-p/4933017#M102362</link>
      <description>Thanks for all points you have given ;-(</description>
      <pubDate>Wed, 12 Oct 2005 07:30:14 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/help-for-script/m-p/4933017#M102362</guid>
      <dc:creator>Eric SAUBIGNAC</dc:creator>
      <dc:date>2005-10-12T07:30:14Z</dc:date>
    </item>
  </channel>
</rss>

