[Makefile] Get Prefix or Suffix from String
source link: http://siongui.github.io/2016/12/29/makefile-get-prefix-or-suffix-from-string/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
[Makefile] Get Prefix or Suffix from String
December 29, 2016
Source code:
Makefile | repository | view raw
STR=1.0.4-1ubuntu0.16.10.1 PREFIX=$(shell echo $(STR) | head -c 5) SUFFIX=$(shell echo $(STR) | tail -c 10) default: @echo "string: \033[92m$(STR)\033[0m" @echo "prefix: \033[92m$(PREFIX)\033[0m" @echo "suffix: \033[92m$(SUFFIX)\033[0m"
shell command head/tail are used to get prefix/suffix from string.
Output:
string: 1.0.4-1ubuntu0.16.10.1 prefix: 1.0.4 suffix: 0.16.10.1
Tested on Ubuntu Linux 16.10, GNU make 4.1-9.
References:
[1][Makefile] Check Installed Package Version on Ubuntu Linux
Author: Siong-Ui Te ∈ Category: Bash
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK