Results 1 to 3 of 3
  1. #1
    Join Date
    Sep 2007
    Posts
    11

    Red face Unanswered: if loop not working

    Hello

    i am trying to remove a line using an input file , but this depends upon user interaction

    here is the sample

    #!/bin/sh
    echo "Please enter whether you want to remove Profile"
    read value1
    if [$value1="y"];then
    sed /movie/d temp.txt> temp3.txt
    else
    echo "Script didnot remove profile"
    fi

    if the user hit the letter 'y' it should search the string movie from temp.txt and remove that line

    Please help me on this .. The above code which i gave won't work as i new to unix shell scripting !!

  2. #2
    Join Date
    Jan 2004
    Location
    Bordeaux, France
    Posts
    320
    Your if statement syntax is invalid
    Code:
    #!/bin/sh
    echo "Please enter whether you want to remove Profile"
    read value1
    if [ "$value1" = "y" ];then
       sed /movie/d temp.txt> temp3.txt
    else
       echo "Script didnot remove profile"
    fi
    Jean-Pierre.

  3. #3
    Join Date
    Sep 2007
    Posts
    11
    Thanks you are right

Posting Permissions

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