0

bash parameter expansion has a few useful function, e.g. substring ,replace,upper,lower. how to combine these function without define temporary parameter?

f="abc.txt"
e=${f:4:3}   #txt
echo ${e^^}  #TXT

I define e to upper the txt. echo ${${f:4:3}^^} can not work. Is it possible omit e. if in java i can write

String f="abc.txt";
System.out.print(f.substring(4,7).toUpperCase());

even, i can

System.out.print("abc.txt".substring(4,7).toUpperCase());
redmark
  • 131
  • 8
  • Bash, unlike Java, is not designed as an application language, it is a *shell*. You can't expect the same level of functionality in both, they are different tools for different jobs. Specifically for this case, shell parsing is done in a completely different way to conventional programming languages. – cdarke May 30 '16 at 09:05

1 Answers1

1

No, this is not possible in bash AFAIK.

To make it possible we would need some sort of prioritization (along-with parsing logic changes) when more than 1 parameter expansion is specified, for which there is no code as of now.

riteshtch
  • 8,629
  • 4
  • 25
  • 38