开发者

How can i delete double quote in bash file.(Linux)

开发者 https://www.devze.com 2023-03-27 20:07 出处:网络
for i in $(some function); do somefunction2 $i; done -su: 0 5 : syntax error in expression (error token is \"5 \")
for i in $(some function); do somefunction2 $i; done

-su: 0 5 : syntax error in expression (error token is "5 ")

My problem is some function return "0 9" I can't use this:

for i in "0 5"; do somefunction2 $i; done

Results are the same

-su: 0 5 : syntax error in expression (error token is "5 ")

but if use this:

for i in 0 5; do somefunction2 $i; done

It works. Some开发者_Python百科 function for loop and echo this

echo -n "$i "

I want return 0 5 not "0 5" How can I do?


This should solve your problem:

eval for i in $(some function); do somefunction2 \$i; done

However, it's not clear from your question where does the su come from ?


You don't need to delete anything:

   function five {
   echo 0;
   echo 5;
   }

   function fiveString {
   echo "0 5";
   }

   for i in `five`;do
   echo process $i;
   done

   for i in $(echo $(fiveString));do
   echo process $i;
   done
0

精彩评论

暂无评论...
验证码 换一张
取 消