<?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: c shell script in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/c-shell-script/m-p/2864605#M821297</link>
    <description>Don't know about csh, but for sh:&lt;BR /&gt;&lt;BR /&gt;##########################&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;&lt;BR /&gt;AFILE='/tmp/yourfile'&lt;BR /&gt;&lt;BR /&gt;grep "hello there" $AFILE&lt;BR /&gt;##########################&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Chuck J</description>
    <pubDate>Mon, 16 Dec 2002 09:24:37 GMT</pubDate>
    <dc:creator>Chuck J</dc:creator>
    <dc:date>2002-12-16T09:24:37Z</dc:date>
    <item>
      <title>c shell script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/c-shell-script/m-p/2864603#M821295</link>
      <description>Hi, everyone,&lt;BR /&gt;&lt;BR /&gt;Please help a beginner with a c shell script... the requirement is: &lt;BR /&gt;the script finds a specified string in each line of a file.  I know that the following command works:&lt;BR /&gt;grep the_string the_file&lt;BR /&gt;&lt;BR /&gt;How can I reach the same result in a c shell? &lt;BR /&gt;&lt;BR /&gt;Thanks</description>
      <pubDate>Sun, 15 Dec 2002 05:27:11 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/c-shell-script/m-p/2864603#M821295</guid>
      <dc:creator>windflower_1</dc:creator>
      <dc:date>2002-12-15T05:27:11Z</dc:date>
    </item>
    <item>
      <title>Re: c shell script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/c-shell-script/m-p/2864604#M821296</link>
      <description>Hi&lt;BR /&gt;I don't see the problem:&lt;BR /&gt;&lt;BR /&gt;------------------------&lt;BR /&gt;#!/bin/csh&lt;BR /&gt;&lt;BR /&gt;grep the_string the_file&lt;BR /&gt;&lt;BR /&gt;-------------------------&lt;BR /&gt;&lt;BR /&gt;Chris&lt;BR /&gt;</description>
      <pubDate>Mon, 16 Dec 2002 06:38:51 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/c-shell-script/m-p/2864604#M821296</guid>
      <dc:creator>Christian Gebhardt</dc:creator>
      <dc:date>2002-12-16T06:38:51Z</dc:date>
    </item>
    <item>
      <title>Re: c shell script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/c-shell-script/m-p/2864605#M821297</link>
      <description>Don't know about csh, but for sh:&lt;BR /&gt;&lt;BR /&gt;##########################&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;&lt;BR /&gt;AFILE='/tmp/yourfile'&lt;BR /&gt;&lt;BR /&gt;grep "hello there" $AFILE&lt;BR /&gt;##########################&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Chuck J</description>
      <pubDate>Mon, 16 Dec 2002 09:24:37 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/c-shell-script/m-p/2864605#M821297</guid>
      <dc:creator>Chuck J</dc:creator>
      <dc:date>2002-12-16T09:24:37Z</dc:date>
    </item>
    <item>
      <title>Re: c shell script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/c-shell-script/m-p/2864606#M821298</link>
      <description>Hi:&lt;BR /&gt;&lt;BR /&gt;There are several ways to do a pattern search in unix script.  You can put any of these commands in a file, then execute the file as a script:&lt;BR /&gt;&lt;BR /&gt;grep pattern file&lt;BR /&gt;sed -n /pattern/p file&lt;BR /&gt;awk ' /pattern/ { print $0 } ' file&lt;BR /&gt;&lt;BR /&gt;All three of the above commands give the same output, and all three can be put in a file to execute.&lt;BR /&gt;&lt;BR /&gt;Tom</description>
      <pubDate>Mon, 16 Dec 2002 12:23:44 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/c-shell-script/m-p/2864606#M821298</guid>
      <dc:creator>Tom Jackson</dc:creator>
      <dc:date>2002-12-16T12:23:44Z</dc:date>
    </item>
    <item>
      <title>Re: c shell script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/c-shell-script/m-p/2864607#M821299</link>
      <description>windflower,&lt;BR /&gt;&lt;BR /&gt;Putting the grep statement in a script is a no brainer, but what is probably more important is what you want to do when you "FIND" the string in the_file ???&lt;BR /&gt;&lt;BR /&gt;live free or die&lt;BR /&gt;harry</description>
      <pubDate>Mon, 16 Dec 2002 12:45:05 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/c-shell-script/m-p/2864607#M821299</guid>
      <dc:creator>harry d brown jr</dc:creator>
      <dc:date>2002-12-16T12:45:05Z</dc:date>
    </item>
    <item>
      <title>Re: c shell script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/c-shell-script/m-p/2864608#M821300</link>
      <description>First, I'd suggest some heavy reading in some scripting books.  There are literally thousands available, some covering shell specifics (I.E. Borne Shell Scripting), and others cover many. (I.E.  Basic Unix Scripting). &lt;BR /&gt;&lt;BR /&gt;In both of your questions, you are asked to write a "wrapper" script.  This is also very basic scripting. &lt;BR /&gt;&lt;BR /&gt;First, Borne and Korne shell have C like variable setting.&lt;BR /&gt;I.E.&lt;BR /&gt;I=1&lt;BR /&gt;NAME="john"&lt;BR /&gt;&lt;BR /&gt;C-shell uses more basic like language.&lt;BR /&gt;I.E.&lt;BR /&gt;set I=1&lt;BR /&gt;set NAME="john"&lt;BR /&gt;&lt;BR /&gt;In the shell, you need to know what the STDARGS is, and how to use it.  Borne/Korn shell use stdargs differently than C-Shell.&lt;BR /&gt;&lt;BR /&gt;You also need to look at the return value from your command to know if the command failed, or your string does not exist.&lt;BR /&gt;&lt;BR /&gt;So the logic you need is to do this.  Look for 2 arguments: filename and search_string.  &lt;BR /&gt;&lt;BR /&gt;1.  Process input and look for entry of both arguments.&lt;BR /&gt;  2 strings=continue  &lt;BR /&gt;  less than 2 strings=exit with error.&lt;BR /&gt;2.  test to see if string 1 or string 2 is a filename.  Hint:  if ( -f "name") ; endif will test to see if name is a file.&lt;BR /&gt;3.  use argument not a file with grep on the file.  &lt;BR /&gt;Look at the return code from grep.&lt;BR /&gt;If you have matching strings, they will print to stdout unless you specify otherwize.  If grep returns a 0, and no lines then grep was fine, but nothing was found.  If grep returns anything greater than 0, then grep failed.&lt;BR /&gt;&lt;BR /&gt;While many here including myself could write your assignment for you, it would be much better for you to learn and do it on your own.&lt;BR /&gt;&lt;BR /&gt;All of the information needed for this work can be found in "Unix in a Nutshell", published by O'Reilly and Associates.  There are sections for basic Borne/Korn and C-Shell scripting.  You may have to read 2-4 pages in the C-Shell section to do this script.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Shannon</description>
      <pubDate>Mon, 16 Dec 2002 17:09:57 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/c-shell-script/m-p/2864608#M821300</guid>
      <dc:creator>Shannon Petry</dc:creator>
      <dc:date>2002-12-16T17:09:57Z</dc:date>
    </item>
  </channel>
</rss>

