Digit | is there a way to get "apt search" output only 1 line per result? or a way to get "apt-cache search" to show version numbers (still 1 line per result)? | 02:15 |
---|---|---|
Digit | i mean, without elaborate awking/sedditing/etc | 02:15 |
gnarface | just pipe the output to less | 02:17 |
gnarface | apt-cache search . |less | 02:17 |
gnarface | then you can use the basic keyboard navigation at least | 02:18 |
Digit | uhh, nope. doesnt do what i'm looking for at all. worsens. | 02:18 |
gnarface | i know it doesn't do what you asked for, but it was the closest you're gonna get without learning anything | 02:19 |
gnarface | fyi "apt-cache search" does support some regexp syntax though, more than just basic wildcards | 02:19 |
Digit | e.g. search result would show "packagename packageversion" | 02:20 |
gnarface | you want "apt-cache show [package name]" | 02:20 |
gnarface | the version will be in the output | 02:20 |
Digit | i'll probably just end up sedditing my way to 1 line output. | 02:21 |
gnarface | combining search and show in the way you suggest, would as far as i know require "elaborate awking/sedditing/etc" | 02:21 |
gnarface | maybe try aptitude? some people like it more | 02:21 |
gnarface | it might include versions in the output, i'm not sure | 02:22 |
Digit | yeah, gnarface that's again far from what i want. XD your suggestions are adding lines, not removing them. seems a simple requirement i would have thought would be more popularly sought. search output with just "packagename packageversion" | 02:22 |
gnarface | oh you can search with the package version | 02:22 |
gnarface | it just isn't shown in the output of search | 02:23 |
Digit | needed for inclusion in scripts. idk aptitude well... it's all tui, no? | 02:23 |
gnarface | but the search regexp itself does actually search against the whole output of all the package headers and such too | 02:23 |
gnarface | so you can definitely search by package and version if you know the package header format and regexp | 02:23 |
gnarface | for most packages, typically they don't store more than one version in the repos for an extended period of time though, so there's a limit to the usefulness of that | 02:24 |
gnarface | "dpkg -l" will list versions of packages too, but only if they're already installed | 02:29 |
* Digit nods | 02:29 | |
gnarface | hmmm. ack, i may be wrong that the Version tag is even searched by apt-cache search.... | 02:30 |
Jjp137 | Digit, try: dpkg-query --show package | 02:32 |
Jjp137 | you can use --showformat to control the output; refer to the man page, as always :) | 02:32 |
gnarface | as for aptitude, i don't know if there's a way to call it non-interactively. i just assumed there would be but it would not be the default. | 02:32 |
Digit | hrm. dpkg-query --show teeworlds (the package i'm testing on) gives: dpkg-query: no packages found matching teeworlds. that another case of only installed packages? | 02:34 |
gnarface | i don't actually know for sure but i assume so | 02:34 |
gnarface | dpkg is typically for direct package manipulation | 02:35 |
gnarface | apt* is what adds repository support | 02:35 |
Digit | coulda also been complications from the complexity of my system. | 02:35 |
Jjp137 | oh nah I didn't consider that part, oops | 02:35 |
gnarface | i'm guessing there will have to be two calls here, one to "apt-cache search" to get a list of package names, and another to "apt-cache show", "apt-cache showpkg", or "apt-cache showsrc" | 02:37 |
gnarface | (to grep for versions) | 02:37 |
gnarface | more fields than just the package name are searched by "apt-cache search" but "Version: " doesn't appear to be one of them. i'm having trouble isolating exactly which by testing | 02:38 |
gnarface | maybe "Provides: " is searched | 02:40 |
gnarface | in addition to package name and description | 02:40 |
gnarface | at some point i must have caught a version number in there and thought "Version: " was included, sorry | 02:41 |
gnarface | i'm not even sure Description is searched actually now with amprolla | 02:42 |
gnarface | i recall someone complaining about that before and now i'm seeing it | 02:42 |
Jjp137 | the short description (the one-liner) would be | 02:42 |
Jjp137 | the long description...uh yea it disappears if the package came from Debian | 02:42 |
* Digit elaborated: apt-cache show bc | cut -d" " -f2 | head -n 2 | paste -d " " - - | 02:43 | |
Digit | :D | 02:43 |
Digit | tho, that still needs work for more elaborate multi result output. | 02:43 |
gnarface | apt-cache show bc|grep ^Version | 02:44 |
gnarface | ? | 02:44 |
gnarface | (grep has similar regexp syntax to apt-cache search) | 02:45 |
Digit | mm, yeah, i should grep wiser | 02:45 |
gnarface | i think you can trust the field names to all be labeled like "Fieldname: " | 02:46 |
gnarface | i don't know if you can trust them to always be in the same order | 02:46 |
gnarface | or even to all be present every time | 02:46 |
gnarface | but they should always start on their own line | 02:47 |
gnarface | so you should be able to grep for "^Fieldname: " | 02:47 |
Xenguy | Digit: Reading quickly, but this sounds like a grep exercise, and I'm still not clear on what your actual requirement is, besides '1 line', of 'something' | 02:55 |
Xenguy | Oh, gnarface has it sorted, so ignore my comment | 02:56 |
Digit | package search output of "packagename package version". yeah. well, had hoped i could skip the text manipulation exersize i'm going through. now i'm going through it, it doesnt hurt so much. n_n | 02:56 |
Xenguy | apt-cache show grep |grep version | 02:58 |
Xenguy | = ) | 02:58 |
Digit | s/package version/packageversion/ meh, whatever. u get what i mean. like "bc 1.06.95-9+b3" or "teeworlds 0.6.5+dfsg-1~deb9u1", but want it (and am working on) getting it so it works for multiple results n partial package names in the search. | 02:59 |
Xenguy | Should be: apt-cache show grep |grep -i version | 02:59 |
Digit | Xenguy: that doesnt have the package name. we're past that. | 03:00 |
Xenguy | picky picky | 03:00 |
Digit | hehe | 03:00 |
Xenguy | ; -) | 03:00 |
Digit | apt-cache show bc | cut -d" " -f2 | head -n 2 | paste -d " " - - ...&... apt-cache show teeworlds | egrep '^Version|^Package' | paste -d " " - - | sed 's/Package: //g' | sed 's/Version: //g' ... are two early versions inadequate for multiple results. gonna make one from "apt search" output that should do the job. ... might take a break first. | 03:01 |
Xenguy | weeeeeeee, pipe city! | 03:01 |
Digit | n_n | 03:01 |
Xenguy | Time to play some golf | 03:02 |
Xenguy | But whatever works, right? | 03:02 |
Digit | or from "apt-cache search -f" output | 03:06 |
Jjp137 | do note that apt, as opposed to related commands like apt-get or apt-cache, is more of an end-user tool and can change behavior between versions (see the bottom of apt(8) for details) | 03:06 |
Jjp137 | so I would just use apt-cache for this probably | 03:06 |
Digit | yep yep yep. *nods* :) | 03:06 |
Xenguy | Jjp137: I've been trying apt out here and there, and it seems to work quite nicely... | 03:07 |
Jjp137 | yea for interactive use it's fine | 03:07 |
Xenguy | I also read that it is more or less compatible/interchangeable with apt-get, so that is a bonus IMHO | 03:07 |
Jjp137 | but for scripts, prefer apt-get, apt-cache, etc. | 03:08 |
Xenguy | Jjp137: Yeah, they say don't script it | 03:08 |
Xenguy | Exactly | 03:08 |
Digit | ooh! my prior version, all i need to do to make it work is s/apt-cache show/apt-cache search -f/. :D pleasant. | 03:09 |
Xenguy | Golf! | 03:10 |
Xenguy | Well done | 03:10 |
Digit | n_n thnx for putting up with me. thnx for the suggestions n help, all. :) | 03:12 |
Xenguy | I'm tempted to engage the exercise myself, but, on 2nd thought, nah ; -) | 03:12 |
Xenguy | Glad to have you here | 03:12 |
Digit | well, in my script, apt-cache search -f "$argv" | egrep '^Version|^Package' | paste -d " " - - | sed 's/Package: //g' | sed 's/Version: //g' is not as simple&pretty as just apt-cache search "$argv", but it's nice to get consistent output with name and version, without bloating output to multi-line per package. :) nnnnnice. :) | 03:16 |
Digit | (that $argv's fish, change to whatever that is for your bash, i forget... $1 or something?) | 03:17 |
* Xenguy cheats: apt-cache show grep |grep Package && apt-cache show grep |grep Version | 03:18 | |
* Digit tries that with teeworlds package, and tries it with s/show/search -f/, sticks to what he has | 03:20 | |
Xenguy | $ apt-cache show teeworlds |grep Package && apt-cache show grep |grep Version | 03:24 |
Xenguy | Package: teeworlds | 03:24 |
Xenguy | ^^ Scratch that | 03:24 |
Xenguy | $ apt-cache show teeworlds |grep Package && apt-cache show grep |grep Version | 03:24 |
Xenguy | Package: teeworlds | 03:24 |
Xenguy | Version: 2.27-2 | 03:24 |
Xenguy | Then I'd just use a text editor macro to massage the output | 03:25 |
Xenguy | But that's a quick and dirty approach | 03:25 |
Xenguy | If you've got a better solution, then go for it of course | 03:25 |
Digit | yeah, already pasted it in here a couple times. ;D | 03:31 |
Xenguy | Well that's what I meant of course | 03:34 |
Xenguy | "There's more than one way to skin a..." Er, n/m | 03:34 |
Digit | more than one way to egrep ;D | 03:35 |
Xenguy | As the Perl Mongers used to say (and perhaps still do): TMTOWTDI (There's More Than One Way To Do It!) | 03:39 |
Xenguy | (And with Perl, that was most certainly true) | 03:39 |
Xenguy | (tim-toady) | 03:51 |
Venker | hi people | 09:38 |
gnarface | yo | 09:39 |
Hund | Hey | 16:22 |
Generated by irclog2html.py 2.17.0 by Marius Gedminas - find it at https://mg.pov.lt/irclog2html/!