![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| how to? launch command with string of command line options | TinCanFury | Shell Programming and Scripting | 5 | 04-28-2008 07:06 PM |
| awk and execute command ??? | sabercats | Shell Programming and Scripting | 13 | 03-28-2006 07:12 PM |
| Plz Help : How to use write command to execute command on some other terminal | Aashish | UNIX for Dummies Questions & Answers | 2 | 03-03-2006 12:25 PM |
| How does this command execute? | saneeshjose | UNIX for Dummies Questions & Answers | 3 | 01-03-2006 10:46 AM |
| execute command | neer45 | Shell Programming and Scripting | 2 | 11-25-2001 08:45 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
How to build a command into a string rather than execute the command
I'm trying to populate a command line into a variable. It appears to be executing, instead. Here's an example:
mycmd='' if ...; then $mycmd='sudo ' fi $mycmd=$mycmd 'sed -i prev s/aaa/bbb/' $myfile res=`$mycmd` (I'm also not sure of the best way to execute the command from the variable, either, so any corrections would be appreciated!) Last edited by littlejon; 05-29-2008 at 08:56 PM.. |
|
||||
|
mycmd=$mycmd 'sed -i prev s/aaa/bbb/' (no $ at the beginning of the line) Quote:
Code:
fab@adeon:~$ a="echo hi" fab@adeon:~$ $a hi fab@adeon:~$ eval $a hi Last edited by fabtagon; 05-29-2008 at 09:08 PM.. Reason: 2nd question & markup fix |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|