Loading ...
Sorry, an error occurred while loading the content.
 

A general unix question.

Expand Messages
  • Chris OConnell
    I m writing a program in bourne shell, and am trying to get the output of grep -c FILENAME to a variable. The purpose is to output it to a file: echo
    Message 1 of 4 , Mar 27, 2007
      I'm writing a program in bourne shell, and am trying to get the output of "grep -c FILENAME" to a variable. The purpose is to output it to a file:

      echo VARIABLE:::$title":::"$prodco":::"$reldate":::" $length >> dvdtmp


      Any thoughts?


      ---------------------------------
      The fish are biting.
      Get more visitors on your site using Yahoo! Search Marketing.

      [Non-text portions of this message have been removed]
    • Chris OConnell
      I m writing a program in bourne shell, and am trying to get the output of grep -c FILENAME to a variable. The purpose is to output it to a file: echo
      Message 2 of 4 , Mar 27, 2007
        I'm writing a program in bourne shell, and am trying to get the output of "grep -c FILENAME" to a variable. The purpose is to output it to a file:

        echo VARIABLE:::$title":::"$prodco":::"$reldate":::" $length >> dvdtmp


        Any thoughts?


        ---------------------------------
        The fish are biting.
        Get more visitors on your site using Yahoo! Search Marketing.

        [Non-text portions of this message have been removed]
      • Mike ONeill
        VARIABLE=`grep -c pattern FILENAME`; echo $VARIABLE OUTPUTFILE` The quotes before grep and after OUTPUTFILE are on the key above Tab ... output of grep -c
        Message 3 of 4 , Mar 28, 2007
          VARIABLE=`grep -c 'pattern' FILENAME`; echo $VARIABLE > OUTPUTFILE`

          The quotes before grep and after OUTPUTFILE are on the key above Tab

          --- In suselinuxusers@yahoogroups.com, Chris OConnell <omegahalo@...>
          wrote:
          >
          > I'm writing a program in bourne shell, and am trying to get the
          output of "grep -c FILENAME" to a variable. The purpose is to output
          it to a file:
          >
          > echo VARIABLE:::$title":::"$prodco":::"$reldate":::" $length
          >> dvdtmp
          >
          >
          > Any thoughts?
          >
          >
          > ---------------------------------
          > The fish are biting.
          > Get more visitors on your site using Yahoo! Search Marketing.
          >
          > [Non-text portions of this message have been removed]
          >
        • Aaron Kulkis
          ... 1... please set your line length to something reasonable, like 72. Most of us detest having to reformate someone else s question before replying... 2
          Message 4 of 4 , Mar 28, 2007
            Chris OConnell wrote:
            > I'm writing a program in bourne shell, and am trying to get the output of "grep -c FILENAME" to a variable. The purpose is to output it to a file:
            >

            1... please set your line length to something reasonable,
            like 72. Most of us detest having to reformate someone
            else's question before replying...


            2 VARIABLE=`grep -c FILENAME`

            The general form is:
            VARIABLE=`cmd1 arg1a.. | cmd2 args2a.. | ... cmdN argsN`

            VARIABLE is assigned to the standard output from cmdN
            (the last command of the pipeline contained within the
            backquotes ` `)

            Of course you realize that your grep statement has a syntax
            error. The proper form of grep is (from the grep man page):

            GREP(1) GREP(1)



            NAME
            grep, egrep, fgrep - print lines matching a pattern

            SYNOPSIS
            grep [options] PATTERN [FILE...]
            grep [options] [-e PATTERN | -f FILE] [FILE...]

            DESCRIPTION
            Grep searches the named input FILEs (or standard input if no files are named, or the file name -
            is given) for lines containing a match to the given PATTERN. By default, grep prints the match‐
            ing lines.

            In addition, two variant programs egrep and fgrep are available. Egrep is the same as grep -E.
            Fgrep is the same as grep -F.






            > echo VARIABLE:::$title":::"$prodco":::"$reldate":::" $length >> dvdtmp
            >


            >
          Your message has been successfully submitted and would be delivered to recipients shortly.