Re: How do I get just the pkg version in pkg-search results?
- In reply to: list_freebsd_a_bluerosetech.com: "How do I get just the pkg version in pkg-search results?"
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 22 Mar 2024 19:28:58 UTC
> ---------------------------------------- > From: <list_freebsd@bluerosetech.com> > Date: Mar 22, 2024, 12:10:53 AM > To: <freebsd-questions@freebsd.org> > Subject: How do I get just the pkg version in pkg-search results? > > > I can do a search like this: > > # pkg search -qe -S name sqlite3 > sqlite3-3.45.1,1 > > But all I need is the version string. If the version field was exposed > like other fields, I could do this: > > # pkg search -qe -S name -L version sqlite3 > 3.45.1,1 > > But that's not (currently) an option. > > Is it guaranteed that a version string never contains '-'? That is, is > the last '-' in the pkg-name string always going to be the delimiter > between the name-flavor substring, and the version substring? > lain already answered your question with the best way to get the version string, but to add some recent history: A few months back the FreeBSD team switched packages from using .txz extensions to .pkg, and used tildes (~) instead of dashes (-), which broke `pkg clean' or `pkg autoclean', I forget which. During that time I wrote an awk script to clear my various pkg repos using the following pattern matches: { sub(/\/.+\//, "") } # strip pathname from filename /[-~][[:alnum:]]{10}.(txz|pkg)$/ { # binaries end in 10-alnum chars ext = substr($0, match($0, /.(pkg|txz)$/)) # bin file extension ver = substr($0, 0, match($0, /[-~][^-~]+$/) -1) # package version name pkg = substr(ver, 0, match(ver, /-[^-]+$/) -1) # package base name -- Sent with https://mailfence.com Secure and private email