Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

5
  • I was looking for a clean way. A readable way. This is the best ever solution. Commented Apr 2, 2015 at 6:52
  • 3
    You should enclose the entire expression in double quotes (echo "${vector[index]//\"/}") in case the value has leading spaces, trailing spaces, or embedded strings of multiple spaces.  Note that this will remove embedded (internal) quotes as well as the ones at the beginning and end.  (And the ; at the end of the command line is unnecessary.) Commented Apr 2, 2015 at 7:32
  • @Scott in my case it does not happen because the scrip puts quotations. but thanks for mentioning. Commented Apr 2, 2015 at 7:36
  • I don't understand which part of my comment you're responding to, or how your comment makes sense as a response to mine. Commented Apr 2, 2015 at 7:38
  • @Scott the ; at the end of the command was introduced by pasting the snipped into my terminal. It is not in the OP's snippet. I'll remove it from the snippet. There are several other things that could be optimized, but this wasn't the requirement in this question, so I keep it the way it was posted by the OP. Commented Apr 2, 2015 at 7:48