Sed question

J dreadpiratejeff at gmail.com
Fri Sep 23 13:21:29 UTC 2011


2011/9/23 Markus Schönhaber <ubuntu-users at list-post.mks-mail.de>:
> 23.09.2011 13:37, Oliver Marshall:
>
>> FileVersion:     14.0.4756.1000
>>
>> And I want to remove everything before the 1, leaving;
>>
>> 14.0.4756.1000
>>
>> I thought that the following should do it but it doesn't appear to work. Any ideas what I should be using?
>>
>> sed "/^FileVersion: */!d; s///;q"
>>
>> (This is using SED for windows, but as far as I can see the syntax is the same).
>
> $ echo "FileVersion:     14.0.4756.1000" | sed '/^FileVersion: */!d; s///;q'
> 14.0.4756.1000
>
> (this is using sed on Lucid)
>
> Some comments:
> - Depending on the shell you use, the '!' might be treated specially if
> not surrounded by single quotes and thus might not make it literally to
> the sed command line.
> - ' *' matches spaces, not, for example, TABs.

Any particular reason for using sed for this, beyond the learning experience?

bladernr at klaatu:~/development$ echo "FileVersion: 14.0.4756.1000" |
awk '{print $2}'
14.0.4756.1000




More information about the ubuntu-users mailing list