From nobody Fri Mar 22 19:28:58 2024 X-Original-To: freebsd-questions@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4V1XSc5nMNz5F9J3 for ; Fri, 22 Mar 2024 19:29:04 +0000 (UTC) (envelope-from sysadmin.lists@mailfence.com) Received: from wilbur.contactoffice.com (wilbur.contactoffice.com [212.3.242.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4V1XSc3Vgkz41nY for ; Fri, 22 Mar 2024 19:29:04 +0000 (UTC) (envelope-from sysadmin.lists@mailfence.com) Authentication-Results: mx1.freebsd.org; none Received: from fidget.co-bxl (fidget.co-bxl [10.2.0.33]) by wilbur.contactoffice.com (Postfix) with ESMTP id B4B291364; Fri, 22 Mar 2024 20:29:01 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1711135741; s=20210208-e7xh; d=mailfence.com; i=sysadmin.lists@mailfence.com; h=Date:From:To:Message-ID:In-Reply-To:References:Subject:MIME-Version:Content-Type:Content-Transfer-Encoding; l=1589; bh=oS1X1qoMyD9U8ULEwIBdoWiiCIMJHW0QWe09KbGFDgA=; b=elG54QM5Hu1awlzBchWJZxrtaisVnLi/ZvjXR+TnMgjaxJrdMptoMVJs5stf3w/i Trg1fJtCrBaFYIQNS2oBMW6eJNwoTHkFc+xKQMFsEJL0CER2eOycx5jMw/YcvtCPMpr e7WVu6Upp7a7t3r3Mv6KKP9m/BDtNlNqpZhnhZcA/hkwz8SnHWLbss5qsB69QHbmhB9 v5jun8BnBdWH/XjnihzXQJA5TvrNejcVQfYdHd1DElGYC1b0AO58PAs4Sjid5tJ3K1m BUvBK5VqVxKTnspK9JeDIUOsJXdbboh0E7+GH/LGY/E5H+4s/xIbbw7tPDmxOuXTc/c jL1v7KRMvw== Date: Fri, 22 Mar 2024 20:28:58 +0100 (CET) From: Sysadmin Lists To: list_freebsd@bluerosetech.com, freebsd-questions@freebsd.org Message-ID: <1522700875.2589890.1711135738859@fidget.co-bxl> In-Reply-To: <0b06e637-6b26-4d01-21f5-9d9419c3c64e@bluerosetech.com> References: <0b06e637-6b26-4d01-21f5-9d9419c3c64e@bluerosetech.com> Subject: Re: How do I get just the pkg version in pkg-search results? List-Id: User questions List-Archive: https://lists.freebsd.org/archives/freebsd-questions List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-questions@freebsd.org X-BeenThere: freebsd-questions@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Mailer: ContactOffice Mail X-ContactOffice-Account: com:312482426 X-Spamd-Bar: ---- X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[]; ASN(0.00)[asn:203, ipnet:212.3.242.64/26, country:US] X-Rspamd-Queue-Id: 4V1XSc3Vgkz41nY > ---------------------------------------- > From: > Date: Mar 22, 2024, 12:10:53 AM > To: > 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