I have a variable in a textfile that could look like these three alternatives (1-3 chars):
variable=XXX
variable=V3
variable=U
In my makefile, I read this variable in with grep
VAR=$(shell grep -w "variable=" textfile.txt | cut -c 10-13)
Question:
But I want to to have this variable VAR "right-handed" which means that if variable=U then VAR[0]="", VAR[1]="", VAR[2]="U".
Assuming you have printf available you could simply use...
VAR=$(shell printf '%3s' `grep -w "variable=" textfile.txt | cut -c 10-13`)