0

how is it possible to run these two commands and then truncate them to the end of the curly bracket? thanks

a=g; z="abcdefgh"

echo ${z%%$a*}
error:
echo ${z%%$a:0:4}

echo ${z//ab/01}
error:
echo ${${z//ab/01}:0:4}
  • 1
    If you get an error, you are not using Bash; but this is really unclear. (Also, tangentially, probably review [When to wrap quotes around a shell variable](https://stackoverflow.com/questions/10067266/when-to-wrap-quotes-around-a-shell-variable)) – tripleee Jan 14 '22 at 11:50
  • Or are you trying to ask how to combine parameter expansions? You can't. – tripleee Jan 14 '22 at 11:51
  • 1
    _then truncate them to the end of the curly bracket_ : I find this ununderstandable. You can't truncate a **command**. You can truncate a **string**, typically a string stored in a variable. – user1934428 Jan 14 '22 at 12:21
  • How should that look? I wanted to make it as compact as possible and because of the extensive possibilities of the commands in curly brackets it seemed sensible to me to combine two commands and in the latter to separate the output of the first. – blumenwesen Jan 15 '22 at 18:12

0 Answers0