简体   繁体   English

如何删除 bash 文件中的双引号。(Linux)

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

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:我的问题是一些 function return "0 9" 我不能使用这个:

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 function for loop and echo this一些 function 用于循环并回显此

echo -n "$i "

I want return 0 5 not "0 5" How can I do?我想返回0 5而不是"0 5"我该怎么办?

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?但是,从您的问题中不清楚su来自哪里?

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM