![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | 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 here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to build a command into a string rather than execute the command | littlejon | Shell Programming and Scripting | 1 | 05-29-2008 05:05 PM |
| how to? launch command with string of command line options | TinCanFury | Shell Programming and Scripting | 5 | 04-28-2008 03:06 PM |
| sed command not running | mmunir | Shell Programming and Scripting | 3 | 04-17-2008 11:02 PM |
| inconsistent ls command display at the command prompt & running as a cron job | rajranibl | Linux | 5 | 07-30-2007 05:26 AM |
| running command more than twice in one second? | Terrible | Shell Programming and Scripting | 4 | 12-10-2006 08:45 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
|||
|
Running a String as a command, zsh.
I have a shell script that is building a string that consists of the parts of a command that I want run at the end of the string. So it looks like this:
$PART1=/path/to/command $PART2="-arg1" $PART3="-arg2" and so on. At the end of the command is a list of files I get from a loop and place in its own string. So in the end I end up with: $PART1 $PART2 $PART3 $FILES as the command I want to run. The problem is that when the script is run the command ends up being: /path/to/command -arg1 -arg2 '/path/to/file1 /path/to/file2' if there are any spaces in the file names which there often are. How can I get rid of the single quotes and just have the command be: /path/to/command -arg1 -arg2 /path/to/file1 /path/to/file2 I am doing this as zsh script on OS X. Thanks. |
| Forum Sponsor | ||
|
|
|
|||
|
$FILES is created in this loop:
while read line; do FILES+="${line/ /\ }" done So when I input the files: Photo 119.jpg and Photo 136.jpg echo $FILES Photo\ 119.jpg Photo\ 136.jpg It is more that when the command is run instead of a set space delimitated file names there are single quotes around the list of files and so the command thinks they are all one file. I noticed a similar thread that suggested doing: echo $(command) | sh Which did work. |
|||
| Google The UNIX and Linux Forums |