Reputation: 562
Basically i am creating an update checker for emesene on osx. I need to find out the version number from inside this file: http://emesene.svn.sourceforge.net/viewvc/emesene/trunk/emesene/Controller.py
The version number is found at self.VERSION = 'version' in the file e.g. self.VERSION = '1.6.3'
The version number then needs to be saved in a file
Is this possible using grep?
Upvotes: 2
Views: 3153
Reputation: 342333
you can use awk,
$ awk -F"['-]" '/VERSION[ \t]=/{print $2}' Controller.py
1.6.3
Upvotes: 1
Reputation: 42448
If you can use sed(1)
, then you can extract it with a single command:
sed -n "s/.*self\.VERSION = '\([^']*\)'.*/\1/p" Controller.py > file
Upvotes: 2
Reputation: 19044
grep "self.VERSION = '.*'" Controller.py | cut -d "'" -f 2 > file
Upvotes: 2