<?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: using grep in script in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/using-grep-in-script/m-p/2431393#M767818</link>
    <description>Hi,&lt;BR /&gt;&lt;BR /&gt;Supplement:&lt;BR /&gt;&lt;BR /&gt;When you like to pass a command line argument that contains whitespace as a single positional argument, enclose it in quotes.&lt;BR /&gt;&lt;BR /&gt;Like:&lt;BR /&gt;myscript "This is a test"&lt;BR /&gt;&lt;BR /&gt;$1 will contain the string "This is a test" (without the quotes).&lt;BR /&gt;&lt;BR /&gt;If you want to use it as an argument to yet another command which should consider it as 1 positional argument, you should do&lt;BR /&gt;&lt;BR /&gt;grep "$1" &lt;FILE&gt;&lt;BR /&gt;&lt;BR /&gt;Bye again,&lt;BR /&gt;Rik&lt;/FILE&gt;</description>
    <pubDate>Tue, 18 Jul 2000 16:39:39 GMT</pubDate>
    <dc:creator>RikTytgat</dc:creator>
    <dc:date>2000-07-18T16:39:39Z</dc:date>
    <item>
      <title>using grep in script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/using-grep-in-script/m-p/2431390#M767815</link>
      <description>In the Posix or Bourne shell, I wish to extract lines from a file with strings like "Jul 15". On the command line I can do: &lt;BR /&gt;   cat myfile | grep "Jul 15" &lt;BR /&gt;and this works. When I try this in a script like:&lt;BR /&gt;         cat myfile | grep "Jul 18"&lt;BR /&gt;it works, but when I try to use a variable I can't get the script to work:&lt;BR /&gt;       &lt;BR /&gt;         set ""Jul 15""&lt;BR /&gt;         echo $1&lt;BR /&gt;         cat myfile | grep $1&lt;BR /&gt;&lt;BR /&gt;even though the echo gives "Jul 15" . Also the script:&lt;BR /&gt;         cat myfile | grep $1&lt;BR /&gt;will not work for "Jul 15" as the input argument. I cannot get a script to work with any command line argument that has more than a single string. Does someone know how to do this?&lt;BR /&gt;</description>
      <pubDate>Tue, 18 Jul 2000 16:17:19 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/using-grep-in-script/m-p/2431390#M767815</guid>
      <dc:creator>Dave Chamberlin</dc:creator>
      <dc:date>2000-07-18T16:17:19Z</dc:date>
    </item>
    <item>
      <title>Re: using grep in script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/using-grep-in-script/m-p/2431391#M767816</link>
      <description>In your script try the following:&lt;BR /&gt;&lt;BR /&gt;DATE=`date %'+b +d'`&lt;BR /&gt;grep $DATE &lt;FILE&gt;&lt;BR /&gt;&lt;BR /&gt;I am assuming that you are wanting something to look for dates. This is for the current date.&lt;/FILE&gt;</description>
      <pubDate>Tue, 18 Jul 2000 16:21:26 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/using-grep-in-script/m-p/2431391#M767816</guid>
      <dc:creator>Rick Garland</dc:creator>
      <dc:date>2000-07-18T16:21:26Z</dc:date>
    </item>
    <item>
      <title>Re: using grep in script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/using-grep-in-script/m-p/2431392#M767817</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;Rick is right. The catch is in the difference between single and double quotes. This is sometimes confusing when writing shell scripts.&lt;BR /&gt;&lt;BR /&gt;Bye,&lt;BR /&gt;Rik</description>
      <pubDate>Tue, 18 Jul 2000 16:31:14 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/using-grep-in-script/m-p/2431392#M767817</guid>
      <dc:creator>RikTytgat</dc:creator>
      <dc:date>2000-07-18T16:31:14Z</dc:date>
    </item>
    <item>
      <title>Re: using grep in script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/using-grep-in-script/m-p/2431393#M767818</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;Supplement:&lt;BR /&gt;&lt;BR /&gt;When you like to pass a command line argument that contains whitespace as a single positional argument, enclose it in quotes.&lt;BR /&gt;&lt;BR /&gt;Like:&lt;BR /&gt;myscript "This is a test"&lt;BR /&gt;&lt;BR /&gt;$1 will contain the string "This is a test" (without the quotes).&lt;BR /&gt;&lt;BR /&gt;If you want to use it as an argument to yet another command which should consider it as 1 positional argument, you should do&lt;BR /&gt;&lt;BR /&gt;grep "$1" &lt;FILE&gt;&lt;BR /&gt;&lt;BR /&gt;Bye again,&lt;BR /&gt;Rik&lt;/FILE&gt;</description>
      <pubDate>Tue, 18 Jul 2000 16:39:39 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/using-grep-in-script/m-p/2431393#M767818</guid>
      <dc:creator>RikTytgat</dc:creator>
      <dc:date>2000-07-18T16:39:39Z</dc:date>
    </item>
    <item>
      <title>Re: using grep in script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/using-grep-in-script/m-p/2431394#M767819</link>
      <description>It works fine if grep "$1" used instead of grep $1. Thanks for the help.</description>
      <pubDate>Tue, 18 Jul 2000 18:48:37 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/using-grep-in-script/m-p/2431394#M767819</guid>
      <dc:creator>Dave Chamberlin</dc:creator>
      <dc:date>2000-07-18T18:48:37Z</dc:date>
    </item>
  </channel>
</rss>

