简体   繁体   中英

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:

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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