Find the answer to your Linux question:
Results 1 to 4 of 4
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    [Bash] execute string as command


    Hi,

    I am trying to execute a string as command.

    Code:
    txt="echo \"abc\""
    `$txt`
    result
    Code:
    ./test.sh: line 2: "abc": command not found
    What am I doing wrong?

    Thanks.

    Michael

  2. #2
    Linux Engineer Javasnob's Avatar
    Join Date
    Jul 2005
    Location
    Wisconsin
    Posts
    942
    You might want to try the eval shell command instead of the backticks; maybe that'll work.
    Flies of a particular kind, i.e. time-flies, are fond of an arrow.

    Registered Linux User #408794

  3. #3

    Thumbs up

    Quote Originally Posted by Javasnob
    You might want to try the eval shell command instead of the backticks; maybe that'll work.
    Thanks, works like a charm.

  4. $spacer_open
    $spacer_close
  5. #4
    used it without the backtick and it worked!

    regards,
    borncrusader

Posting Permissions

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