regex - Sed command on Linux only matches 1, where on Solaris multiple matches are found -
note i'm beginner sed.
we make use of sed-command looks in output of clearcase command , obtains names of users view:
<clearcase output> | sed -n "/development streams:/,// s/[^ ]* *views: *\([^_ ]*\)_.*/\1/p"
(example clearcase output:
project: project:xx0.0_xx0000@/xxxx/xxxxx_xxxxxxxx0 project's mastership: xxxxxxxxx@/xxxx/xxxxx_xxxxxxxx0 project folder: folder:xx0.0@/xxxx/xxxxx_xxxxxxxx0 (rootfolder/xxxxxxxx/xx0.0) modifiable components:component:00000000000@/xxxx/xxxxxx_xxxxxxxx0 component:xxxxxxx_xxxxxxx@/xxxx/xxxxxx_xxxxxxxx0 component:xxxxxxxxxxxxxx_x@/xxxx/xxxxxx_xxxxxxxx0 component:xxxxx@/xxxx/xxxxxx_xxxxxxxx0 component:xxxxxx_xxxxxxxxxxx@/xxxx/xxxxxx_xxxxxxxx0 integration stream: stream:xx0.0_xx0000_integration@/xxxx/xxxxx_xxxxxxxx0 (fi: nemelis) integration views: olduser_xx0.0_xx0000_int - properties: dynamic ucmview readwrite nshareable_dos nemelis_xx0.0_xx0000_int - properties: dynamic ucmview readwrite nshareable_dos otheruser_xx0.0_xx0000_int - properties: dynamic ucmview readwrite nshareable_dos development streams: stream:nemelis_xx0.0_xx0000@/xxxx/xxxxx_xxxxxxxx0 [unlocked] - no rebase or delivery pending. views:nemelis_xx0.0_xx0000 stream:otheruser_xx0.0_xx0000_streamidentifier@/xxxx/xxxxx_xxxxxxxx0 [unlocked] - no rebase or delivery pending. views:otheruser_xx0.0_xx0000_streamidentifier
)
on solaris output:
nemelis
otheruser
but on (redhat-)linux first name given.
(note: i've looked on stackoverflow , found comments sed greedy on posix / gnu , perl should used (see non greedy regex matching in sed?). i've tried fix perl, ran forrest of problems p @ end, using "//", "|", missing operator before < token >, etcetera, hence post here)
not sure you're trying achieve specifying address //
. imply should end of file or blank line. use $
address in former case, , /^$/
in latter.
the following might work you:
sed -n "/development streams:/,$ s/[^ ]* *views: *\([^_ ]*\)_.*/\1/p"
from manual:
$
address matches last line of last file of input, or last line of each file when `-i' or `-s' options specified.
Comments
Post a Comment