PDA

View Full Version : [SOLVED] Little text file trimming



Intrepid Ibex
July 17th, 2010, 08:36 PM
Hi, dear sir(s)!

How can I trim this piece of text with sed, head or whatever:

# [version=0]
songbird.version=1.9.0a
songbird.branch=trunk
songbird.build.number=1759
songbird.build.startRevision=19163
songbird.build.endRevision=19171
songbird.build.sourceRoot=http://publicsvn.songbirdnest.com/client/trunk
songbird.translate.sourceRoot=https://svn.songbirdnest.com/client/trunk
songbird.translate.moz.langpacks.location=https://svn.songbirdnest.com/vendor-binaries/trunk/noarch/mozlocalization
songbird.translate.moz.langpacks.rev=11764
songbird.translate.moz.langpackList.location=https ://svn.songbirdnest.com/vendor/trunk/mozbrowser/locales/shipped-locales
songbird.translate.moz.langpackList.rev=11307
...to just show the number of the "songbird.build.number=" line:

1759
...and separately the version of the "songbird.version=" line:

1.9.0a
There's many ways of achieving this but I'd really appreciate, if someone posted a non-ugly solution.
Thanks! Have some of this popcorn for being so kind to answer: :popcorn:

ju2wheels
July 17th, 2010, 08:46 PM
...to just show the number of the "songbird.build.number=" line:

1759




grep "songbird.build.number" /path/to/songbirdfile.conf | cut -d "=" -f2




...and separately the version of the "songbird.version=" line:

1.9.0a




grep "songbird.version" /path/to/songbirdfile.conf | cut -d "=" -f2

soltanis
July 17th, 2010, 08:55 PM
awk -F "=" '/(version|number)/{print $2}' /path/to/file


More than one way to do it.

Intrepid Ibex
July 17th, 2010, 09:35 PM
Thanks, hope the popcorn's good.

E:

More than one way to do it.
That's why I was so cleaver:

There's many ways of achieving this but I'd really appreciate, if someone posted a non-ugly solution.

ghostdog74
July 24th, 2010, 04:36 AM
$ sed -r -n '/songbird/s/.*(version|build.number)=//p' file
1.9.0a
1759