3

To print part of the string, replace , with . I use command:

echo "${q:16:6}" | sed 's/,/./'

Is it possible to use something like:

echo "${q:16:6/,/.}"

because it does not work?

1 Answer 1

10

You can't stack/nest parameter expansion in Bash, so not even

echo "${${q:16:6}/,/.}"

will work. (Nested expansions like that do work in Zsh, though.)

If you want to stay within Bash, you'll need to use a temporary variable:

foo="${q:16:6}"
echo "${foo/,/.}"

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .