Find the answer to your Linux question:
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 11
in my FC7, lets say i write the code in BASH or AWK in a file called hello.awk or just hello: print " hello world "; or echo "hello world" ...
  1. #1
    Just Joined!
    Join Date
    Jul 2007
    Posts
    34

    can't define string in BASH or AWK

    in my FC7, lets say i write the code in BASH or AWK in a file called hello.awk or just hello:

    print " hello world ";

    or

    echo "hello world"


    when i ./hello.awk or ./hello the terminal complains of undefined string: hello(?)world? is it because of my " " double quotations? because in my FC7 it seems smaller. if i copy paste a same statement with the normal double quotations, it works!. is there a way to change the double quotations to the normal one like this " "?


    i hope u guys can help me

  2. #2
    Just Joined! minigeek's Avatar
    Join Date
    Sep 2005
    Location
    New Zealand
    Posts
    31
    Hi

    Try these

    hello.awk
    #!/usr/bin/awk -f
    BEGIN {print "Hello, World!"}

    Hello.sh
    #!/bin/sh
    echo "Hello World!"


  3. #3
    Just Joined!
    Join Date
    Jul 2007
    Posts
    34
    ok for example, i copy paste this from my FC7:

    #!/bin/awk

    BEGIN {print ¨Hello¨}

    {total = $1 + $2 + $3}
    {print $1 $2 $3}

    END {}




    and when i run it:

    awk-f total.awk

    awk: total.awk:3: BEGIN {print ¨Hello¨}
    awk: total.awk:3: ^ invalid char '?' in expression


    notice the double quote is a lot smaller. " and ¨. if i remove the #!/bin/awk still error

  4. #4
    Just Joined! minigeek's Avatar
    Join Date
    Sep 2005
    Location
    New Zealand
    Posts
    31
    Quote Originally Posted by cruzerMicro View Post
    ok for example, i copy paste this from my FC7:

    #!/bin/awk

    BEGIN {print ¨Hello¨}

    {total = $1 + $2 + $3}
    {print $1 $2 $3}

    END {}




    and when i run it:

    awk-f total.awk

    awk: total.awk:3: BEGIN {print ¨Hello¨}
    awk: total.awk:3: ^ invalid char '?' in expression


    notice the double quote is a lot smaller. " and ¨. if i remove the #!/bin/awk still error
    Change the #!/bin/awk to #!/usr/bin/awk

    Heres a good website for awk programming AWK Programming

  5. #5
    Linux User
    Join Date
    Aug 2006
    Posts
    458
    Quote Originally Posted by minigeek View Post
    Change the #!/bin/awk to #!/usr/bin/awk
    it doesn't matter. The problem is with the double quote.

  6. #6
    Linux Enthusiast
    Join Date
    Aug 2006
    Posts
    631
    Hi,

    First thing to do if you want to learn something is to read as much as possible about it. There are a bump of information of scripting on the net. In every tutorial or book this is given as the first example. Just Google for it.
    And.... I should begin with Bash scripting.

    Regards

  7. #7
    Just Joined!
    Join Date
    Jul 2007
    Posts
    34
    Quote Originally Posted by ghostdog74 View Post
    it doesn't matter. The problem is with the double quote.


    yse. i think thats the problem. so who know a solution

  8. #8
    Linux User
    Join Date
    Aug 2006
    Posts
    458
    Quote Originally Posted by cruzerMicro View Post
    yse. i think thats the problem. so who know a solution
    just retype it , don't cut and paste.

  9. #9
    Just Joined!
    Join Date
    Jul 2007
    Posts
    34
    Quote Originally Posted by ghostdog74 View Post
    just retype it , don't cut and paste.
    OMG...i have done that how many gezillions of time. the point is that even if i retype the whole thing again, the DOUBLE QUOTATION will still be the cause of error.

  10. #10
    Linux Enthusiast
    Join Date
    Aug 2006
    Posts
    631
    It seems that your keyboard setting is not correct.
    Try to change the default keyboard in Gnome to "US keyboard":

    Code:
    System> Control Center> Hardware> Keyboard> Layouts
    Regards

Page 1 of 2 1 2 LastLast

Posting Permissions

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