Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Trouble with sed and semicolon delimiter...

14 views
Skip to first unread message

Tom Lynch

unread,
Jan 19, 2022, 8:51:02 AM1/19/22
to
Greetings,

I'm having trouble with the sed portion of a bash script. I'm trying to get
all the tags from BitBake recipes. I have the following line:

SRC_URI = "git://bb/foo.git;protocol=ssh;tag=v1.1.0;lfs=0;subpath=pctrlmc/c2cmtd"

What I would like to get is the "v1.1.0" of the "tag=" portion

I'm using the following to parse, since this is a BitBake recipe, I need to account for line extensions, so I run it through a perl script first, but the entire line:

perl -pe 's/\\\n|\s{2,}/ /g' foo.bb | grep SRC_URI | grep -v '#' | sed -r 's#.*tag=(.?+)(;|\s+|\").*#\1#'

What this gets is:

v1.1.0;lfs=0;subpath=pctrlmc/c2cmtd

it's missing the semicolon delimter, if I change the sed to:

sed -r 's#.*tag=(.?+);.*#\1#'

It's still missing the first semicolon

v1.1.0;lfs=0

I need to account for other types of delimiter, thus the (;|\s+|\"), but no matter what I've tried, I can't seem to capture just the tag there. What I'm I doing wrong?

Thanks in Advance for any help!

Tom

Michael F. Stemper

unread,
Jan 19, 2022, 9:29:08 AM1/19/22
to
On 19/01/2022 07.51, Tom Lynch wrote:
> Greetings,
>
> I'm having trouble with the sed portion of a bash script. I'm trying to get
> all the tags from BitBake recipes. I have the following line:
>
> SRC_URI = "git://bb/foo.git;protocol=ssh;tag=v1.1.0;lfs=0;subpath=pctrlmc/c2cmtd"

Are you sure that's what you have? When I execute that line, I get

$ SRC_URI =
"git://bb/foo.git;protocol=ssh;tag=v1.1.0;lfs=0;subpath=pctrlmc/c2cmtd"
SRC_URI: command not found
$

(Give or take the gratuitous line-wrap inserted by Thunderbird)

> What I would like to get is the "v1.1.0" of the "tag=" portion

I know nothing about perl, so I can't help with that.

Can you just use sed?

$
SRC_URI="git://bb/foo.git;protocol=ssh;tag=v1.1.0;lfs=0;subpath=pctrlmc/c2cmtd"
$ echo $SRC_URI | sed 's/.*;tag=//' | sed 's/;.*//'
v1.1.0
$


--
Michael F. Stemper
Nostalgia just ain't what it used to be.

Tom Lynch

unread,
Jan 19, 2022, 11:26:01 AM1/19/22
to
On Wednesday, January 19, 2022 at 9:29:08 AM UTC-5, Michael F. Stemper wrote:

> > SRC_URI = "git://bb/foo.git;protocol=ssh;tag=v1.1.0;lfs=0;subpath=pctrlmc/c2cmtd"
> Are you sure that's what you have? When I execute that line, I get
>
> $ SRC_URI =
> "git://bb/foo.git;protocol=ssh;tag=v1.1.0;lfs=0;subpath=pctrlmc/c2cmtd"
> SRC_URI: command not found

Yes, I should be more specific, this is the BitBake line I'm trying to parse to get the version from,
it's just an example.
>
> Can you just use sed?
>
> $
> SRC_URI="git://bb/foo.git;protocol=ssh;tag=v1.1.0;lfs=0;subpath=pctrlmc/c2cmtd"
> $ echo $SRC_URI | sed 's/.*;tag=//' | sed 's/;.*//'
> v1.1.0

That is a possibility, hadn't thought of breaking it into two sed commands...

Thanks
0 new messages