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?

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/,/.}"

Your Answer

By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.