In Bash I can use printf
to format a string output like this:- (Note how I've added a suffix of W
to the string and that this is not included in the padding)
$ printf "Blah %11.1fW\n" 123 456 78965 5 56
Blah 123.0W
Blah 456.0W
Blah 78965.0W
Blah 5.0W
Blah 56.0W
If I want to prefix the string I could do this:-
$ printf "Blah £%11.1f\n" 123 456 78965 5 56
Blah £ 123.0
Blah £ 456.0
Blah £ 78965.0
Blah £ 5.0
Blah £ 56.0
However note how this results in the padding being applied before the prefix.
How (if at all possible) would I use printf
to prefix the value before padding so the output would be as follows:-
Blah £ 123.0
Blah £ 456.0
Blah £ 78965.0
Blah £ 5.0
Blah £ 56.0
If not possible any Bash solution would be appropriate.