Find the answer to your Linux question:
Results 1 to 3 of 3
ok this one has got me going nuts! I and trying to make a script that looks at a spacific line in a file to se if ther is any ...
  1. #1
    Just Joined!
    Join Date
    Apr 2007
    Posts
    12

    IS it a blank line?

    ok this one has got me going nuts!

    I and trying to make a script that looks at a spacific line in a file to se if ther is any text there. but the problem is no mater what I try I get an error.

    Any thoughts??

    the file "45.txt" has a number of blank lines with no text and when one of these lines are selected is when it error's out.

    Her is what I have so far

    Code:
    #! /bin/csh
    set blank = ""
    set line = $1
    set temp = `cat 45.txt | head -$line | tail -1`
    
    if ( $temp == $blank ) then
      echo "It is blank!"
    else
      echo "It is not blank"
    endif
    I get the following error
    ": Event not found.

    have also tried
    Code:
    #! /bin/csh
    set blank = ""
    set line = $1
    set temp = `cat 45.txt | head -$line | tail -1`
    
    if ( $temp == "" ) then     
      echo "It is blank!"
    else
      echo "It is not blank"
    endif
    but with no luck.

  2. #2
    Linux User
    Join Date
    Aug 2006
    Posts
    458
    overall , there should be specific problem that you want to solve. Why don't you specify what problem you are facing ?

  3. #3
    drl
    drl is offline
    Linux Engineer drl's Avatar
    Join Date
    Apr 2006
    Location
    Saint Paul, MN, USA / CentOS, Debian, Solaris, SuSE
    Posts
    1,117
    Hi.

    Most people avoid csh for scripting, finding that the Bourne shell family does not have the irritating quirks of the csh family.

    If you must use csh, then I have found that most error messages involving "events" are related to the use of "!". Remove that from the echo line and try again.

    I tried to reproduce your problem with a more modern version of csh called tcsh, and I was not successful, so another alternative might be to try that. Here is a forced example of an event message:
    Code:
    #!/bin/csh
    
    echo Here is !2000
    Producing:
    Code:
    % ./s2
    2000: Event not found.
    Best wishes ... cheers, drl
    Welcome - get the most out of the forum by reading forum basics and guidelines: click here.
    90% of questions can be answered by using man pages, Quick Search, Advanced Search, Google search, Wikipedia.
    We look forward to helping you with the challenge of the other 10%.
    ( Mn, 2.6.n, AMD-64 3000+, ASUS A8V Deluxe, 1 GB, SATA + IDE, Matrox G400 AGP )

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...