基本上我在osx上为emesene创建更新检查程序。我需要找到此文件中的版本号:http://emesene.svn.sourceforge.net/viewvc/emesene/trunk/emesene/Controller.py
版本号可在文件中的self.VERSION ='version'中找到,例如self.VERSION ='1.6.3'
然后需要将版本号保存在文件
中这可以使用grep吗?
答案 0 :(得分:2)
grep "self.VERSION = '.*'" Controller.py | cut -d "'" -f 2 > file
答案 1 :(得分:2)
如果您可以使用sed(1)
,则可以使用以下命令提取它:
sed -n "s/.*self\.VERSION = '\([^']*\)'.*/\1/p" Controller.py > file
答案 2 :(得分:1)
你可以使用awk,
$ awk -F"['-]" '/VERSION[ \t]=/{print $2}' Controller.py
1.6.3