ocehb: (Default)
ocehb ([personal profile] ocehb) wrote2018-10-11 03:27 pm
Entry tags:

Трюк для print -P -f

Команда print имеет два замечательных флага, -P (использование
управляющих последовательностей из prompt), и -f (использование
printf-последовательностей):

# print -f "Pi: %.02f\\n" 3.1415936
Pi: 3.14
# print -P "%D{%D %T}"
10/11/18 15:18:32

Напрямую они не совместимы:

# print -P -f "%D{%D %T} %s\\n" test
print: %D: invalid directive
# print -P -f "%%D{%%D %%T} %s\\n" test
%D{%D %T} test


Но есть трюк!
# print -P -f "%s %s\\n" "%D{%D %T.%1.}" "%F{red}test%f"
10/11/18 15:22:40.7 test

Post a comment in response:

This account has disabled anonymous posting.
If you don't have an account you can create one now.
HTML doesn't work in the subject.
More info about formatting

If you are unable to use this captcha for any reason, please contact us by email at support@dreamwidth.org