LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 06-25-2006, 11:56 PM   #1
michael_hk
LQ Newbie
 
Registered: Jun 2006
Distribution: Red Hat 9.0
Posts: 4

Rep: Reputation: 0
[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
 
Old 06-26-2006, 12:30 AM   #2
alunduil
Member
 
Registered: Feb 2005
Location: San Antonio, TX
Distribution: Gentoo
Posts: 684

Rep: Reputation: 62
I don't totally understand what you are trying to do, but if you need to send a command into a string there are couple of tricks:

Code:
$(command)
or

Code:
foo=`code`
` == backtick (found under the tilde, ~, key)

Regards,

Alunduil

P.S. If this isn't correct, just post back with more specifics, and I'll try again.
 
Old 06-26-2006, 04:34 AM   #3
michael_hk
LQ Newbie
 
Registered: Jun 2006
Distribution: Red Hat 9.0
Posts: 4

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by alunduil
I don't totally understand what you are trying to do, but if you need to send a command into a string there are couple of tricks:

Code:
$(command)
or

Code:
foo=`code`
` == backtick (found under the tilde, ~, key)

Regards,

Alunduil

P.S. If this isn't correct, just post back with more specifics, and I'll try again.
Thanks for your info. I found what I need is eval.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
escape string in bash script so it can be used in command line BuckRogers01 Linux - Software 15 08-12-2010 10:38 AM
use grep and execute a command if string is found plisken Linux - General 6 07-28-2005 12:06 PM
remote command execute telnet with 1 command MPowers Linux - Networking 2 06-30-2005 07:31 AM
Bash way to tell if String is in String tongar Programming 3 06-16-2005 07:59 AM
Bash command $? failed to execute. Linh Programming 7 05-14-2004 12:11 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:19 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration