Failed to parse arguments: Argument to "--command/-e" is not a valid command: Text ended before matching quote was found for ". (The text was '"cpulimit')

this is what i get when i run the following script in terminal

read -p "Which program u want to limit its processes?" ProgrameName
read -p "Which limitation percentage u want for it ?" limitationPercentage  

getAllPIDRunUnderThisProgram=$( ps -e | grep "$ProgrameName" | awk '{print $1;}')
for i in $getAllPIDRunUnderThisProgram
    gnomeTab+="  --tab -e \"cpulimit -p $i -l $limitationPercentage \" "  

gnome-terminal $gnomeTab

he cant parse the escape character "\" which it has to be used because of the double quote in line 8 gnomeTab+=" --tab -e \"cpulimit -p $i -l $limitationPercentage \" ",so is there a solution to use the double quote as they are mandatory to be used after --tab -e " some commands " and not to get the problem of parsing ?

1 Answer 1


You can change the very first line to

#!/bin/bash -xv

to make the shell show you how it interprets arguments.

Rather than escaping (which leads to eval), you should use arrays to accumulate options:

for i in $getAllPIDRunUnderThisProgram ; do
    gnomeTab+=(--tab -e "cpulimit -p $i -l $limitationPercentage")  

echo "${gnomeTab[@]}"

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .