Find the answer to your Linux question:
Results 1 to 2 of 2
1. have a file with two lines. 2. need to evaluate the first line. The following code works in command prompt: bash-4.1$ line=`head tmp2 -n 1` bash-4.1$ echo "$line line" ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Feb 2007
    Posts
    10

    need help with ksh


    1. have a file with two lines.
    2. need to evaluate the first line.

    The following code works in command prompt:

    bash-4.1$ line=`head tmp2 -n 1`
    bash-4.1$ echo "$line line"
    data1223 line
    bash-4.1$

    The following does not work in a script:
    tmp2='tmp2'
    line1='data1223'
    linecont=`head $tmp2 -n 1`
    echo "$linecont1 linecont1"
    if [ "$linecont1" = " $line1" ];
    then
    echo "table $line1 found" >> kuku
    echo "table $line1 found"
    else
    echo "table $line1 not found" >> kukunotfound
    echo "table $line1 not found"
    fi

    The result:
    linecount1
    table 1223 not found

    TIA

  2. #2
    Just Joined!
    Join Date
    Feb 2007
    Posts
    10
    I found the problem:
    linecont was reserved variable in a "while read linecont do..." clause.

    Sorry for the confusing question.

    Thank you all who might tried to answer my confusing question.

Posting Permissions

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