Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如果我必须提取字符串的一部分,那么在 Makefile 中执行该操作的命令应该是什么。
考虑到我需要一个作为密码一部分的数字。
$(shell pwd) -- /xxx/www/yyy22/zzz
我将如何从 pwd 中提取 22 ?
您的问题并不准确:如果字符串中有多个数字怎么办?你都想要吗?只有第一个?就最后一个吗?
无论如何,你不能用内置的 make 函数来做到这一点。您必须使用外壳;例如返回字符串中的所有数字:
numbers := $(shell pwd | sed 's/[^0-9]//g')