Solved [Solved] Easy way to shorten "meld-1.8.6" to meld?

jb_fvwm2

Daemon

Reaction score: 181
Messages: 1,695

I've a file with many hundreds of the former, in need of the latter so as to pipe an inquiry to the new package tools as to whether a port is installed. (sed? awk? ). OTOH maybe someone knows if one of the pkg commands can do so. With luck, if no one knows here, I could possibly craft a shell script with an if-else loop to do an equivalent with the pkg info command...
 
OP
OP
J

jb_fvwm2

Daemon

Reaction score: 181
Messages: 1,695

Re: Easy way to shorten "meld-1.8.6" to meld?

Thanks for that info, which I've copied. However, I repost now because I thought of maybe a one-liner, converting the numbers to dashes with tr, removing all two-or-more dash sets, reediting the numbers back to port names that should have had them, and then xargs into pkg install or...
 
OP
OP
J

jb_fvwm2

Daemon

Reaction score: 181
Messages: 1,695

Re: Easy way to shorten "meld-1.8.6" to meld?

Unfortunately, this question while useful should maybe not have been asked in this case, I have since posting found that the reinstalls need close attention (vs what may have been... inexperience here) and so will meld or something the file with a pkg [something] | grep equivalent, and "only install" rather than programmatically "install and reinstall", since the latter may not be worth the longer time needed to complete.
 

wblock@

Administrator
Staff member
Administrator
Moderator
Developer

Reaction score: 3,638
Messages: 13,850

It's not 100% reliable to just remove the string after dashes, since some ports have dashes in the name (I think). But:

Code:
% sh
$ name="meld-1.8.6"
$ echo $name
meld-1.8.6
$ echo ${name%%-*}
meld
 
OP
OP
J

jb_fvwm2

Daemon

Reaction score: 181
Messages: 1,695

Unfortunately, if it was just meld I wouldn't maybe post. But it is p5-HTML-Summary-0.019 ; p5-HTML-SimpleParse-0.12; p5-HTML-Template-Pro-0.9510 ; p5-Net-Amazon-S3 etc. (Perl substr?). With /var/db/pkg/ files I could grep ; awk ; gtr ; sed in a pipe construct, bit by bit expanding it, until it could run automatically under portmaster. All that has been obsoleted in this case with pkg2ng [and my lack of SQL expertise]...(I've the old directories, but for some reason most of the p5* did not convert and are missing from the database but still installed. ) Maybe pkg-NEW-SOMETHING could take as a parameter the name-number construct, and any or all of: ... tell it it is installed locally, or available remotely, using as its base the port origin and excluding the PORTVERSION, that would be useful certainly, migrating from maybe ruby19 to ruby20 (and the other such instances) for leftover files, and if it appeared quite soon, may even help others yet to migrate to pkg who wish to check their (hopefully backed up) /var/db/pkg against what the new database says is installed...
 

wblock@

Administrator
Staff member
Administrator
Moderator
Developer

Reaction score: 3,638
Messages: 13,850

pkg info -e meld && echo "installed"
 
Top