0

I am writing a script and in between. I am trying to replace all the commas of the string stored in a variable to spaces. basically the variable dpoint contains comma saparated floating point numbers like 0.0,4.2,3.6666

i am using dpoint=${dpoint//,/ } to replace all commas.

here is the exact error what i am getting.

i read this question here. and i found myself doing nothing wrong..(definitely i am doing... can't figure it out).

screenshot of the problem

it has been an hour fixing this error. finally i posted it here what the heck am i doing wrong?

update: i am using dash shell

sanjeevprasad
  • 804
  • 1
  • 6
  • 21
  • 3
    (1) Don't post code as screenshot. – user202729 Aug 14 '18 at 06:59
  • 2
    (2) Please post a [mcve]. The surrounding code may cause the bug. – user202729 Aug 14 '18 at 07:01
  • Which shell are you using to execute the script? What’s its shebang? How do you run it? `${…/…/…}` is a Bash thing. An other way to do it is `dpoint="$(printf '%s' "${dpoint}" | tr ',' ' ')"`. – Biffen Aug 14 '18 at 07:05
  • @Biffen Note that [tag:dash] tag ... – user202729 Aug 14 '18 at 07:06
  • @user202729 I’m also noting the `sh` tag and the Bashism, so I’m guessing there’s some confusion. – Biffen Aug 14 '18 at 07:09
  • using is /bin/sh pointing to dash – sanjeevprasad Aug 14 '18 at 07:11
  • @sanjeev Then wherever you found the `${…/…/…}` notation was for Bash, and won’t work. – Biffen Aug 14 '18 at 07:12
  • @user202729 after visiting the link you provided i think dash does not support this type of Parameter expansion. – sanjeevprasad Aug 14 '18 at 07:12
  • `dash` absolutely does not support the `/` operator. – chepner Aug 14 '18 at 18:51
  • Oh stack overflow... so you blocked me from posting new questions... after this one................ I need to wait for 6 months in order to post new one... as i am unable to find ( sorry fix .) this post. i don't know what to fix... in it.... neither i can delete the post as this is going to count against me... as said here... https://meta.stackexchange.com/questions/86997/what-can-i-do-when-getting-we-are-no-longer-accepting-questions-answers-from-th – sanjeevprasad Sep 24 '18 at 09:43
  • May be I am not contributing well by asking great questions... but... 6 month is still too much for a new question... – sanjeevprasad Sep 24 '18 at 09:45

0 Answers0