environment variable string substitution
Posted on 2005-04-27
The command processor has some handy features that allow you to manipulate environment variables on the fly. For example, you can substitute one sub-string for another like this:
The second command would replace all "0"s with "-"s in the current system time.
You can also retrieve portions of the environment variable like this:
This would display 5 characters of the system time begining at character 3, so if:
returns "01:23:45.67" then the previous command would return "23:45".
The big question is: how do you do both *without* setting a second environment variable to do it?
For example, suppose I want the middle 5 characters of the time (as above) but I also want to replace the colon(:) with an X instead?
I already know I can do this:
this is what I am trying to avoid. :) Thanks!