View previous topic :: View next topic |
Author |
Message |
abduct Apprentice
Joined: 19 Mar 2015 Posts: 215
|
Posted: Fri Jul 20, 2018 1:02 am Post subject: Trim equery list to only show applications |
|
|
Is there a way to trim or filter the `equery list' output so that it only lists applications users can run (or normally would run).
For instance listing for '*' shows 703 results, but many of them are for libs, perl-core, coreutils, etc.
Essentially I want to find all the executables/applications my user can run such as axel, wget, socat, netcat, ffmpeg, etc.
Perhaps there is a better method such as parsing /bin and /usr/bin?
Any tips or tricks to find out this information.
Thanks. |
|
Back to top |
|
|
eccerr0r Watchman
Joined: 01 Jul 2004 Posts: 9677 Location: almost Mile High in the USA
|
Posted: Fri Jul 20, 2018 1:31 am Post subject: |
|
|
Well, there's some trouble: coreutils does contains files people run, and run often -- should this be included? Kind of ambiguous here.
You can also base it on your world file, what you emerged explicitly: /var/lib/portage/world ... _________________ Intel Core i7 2700K/Radeon R7 250/24GB DDR3/256GB SSD
What am I supposed watching? |
|
Back to top |
|
|
Hu Moderator
Joined: 06 Mar 2007 Posts: 21602
|
Posted: Fri Jul 20, 2018 1:53 am Post subject: |
|
|
To find files in the typical paths that you could run, you could start with find /bin /sbin /usr/bin /usr/sbin -perm -o=x. There are some corner cases that this will get wrong, but it's mostly accurate. What are you trying to do? There are many programs that you can run, but probably never will run directly, if at all. |
|
Back to top |
|
|
John R. Graham Administrator
Joined: 08 Mar 2005 Posts: 10587 Location: Somewhere over Atlanta, Georgia
|
Posted: Fri Jul 20, 2018 2:10 am Post subject: |
|
|
Although I agree with Hu's sentiment: Code: | #!/bin/bash
# Proof of concept. Find all executables on the path.
for dir in `sed -e "s/:/ /g" -e "s|~|${HOME}/|g" <<<${PATH}` ; do
find $dir -maxdepth 1 -type f -executable
done | Finds the root-executable programs if you run it as root and the user-executable programs if run as a regular user.
- John _________________ I can confirm that I have received between 0 and 499 National Security Letters. |
|
Back to top |
|
|
abduct Apprentice
Joined: 19 Mar 2015 Posts: 215
|
Posted: Fri Jul 20, 2018 2:48 pm Post subject: |
|
|
The above suggestions will work I guess with a little bit of leg work on my side.
More or less what I was trying to do was create a listing of all commands that are useful but I don't use all the time. For instance the cpulimit application is very useful, but I may not use it for long periods at a time so I may forget that I have it installed.
I'm thinking about organizing them by category, so perhaps basing my work off the world file may be a better option since they are already organized with a category I just have to reorganize the information. |
|
Back to top |
|
|
krinn Watchman
Joined: 02 May 2003 Posts: 7470
|
Posted: Fri Jul 20, 2018 3:15 pm Post subject: |
|
|
to strictly answer the question, here's what you "were" looking for
Code: | equery f "*" | grep "/bin/\|/sbin/" |
(make sure to quote the "*") |
|
Back to top |
|
|
khayyam Watchman
Joined: 07 Jun 2012 Posts: 6227 Location: Room 101
|
Posted: Fri Jul 20, 2018 7:36 pm Post subject: |
|
|
John R. Graham wrote: | Code: | #!/bin/bash
# Proof of concept. Find all executables on the path.
for dir in `sed -e "s/:/ /g" -e "s|~|${HOME}/|g" <<<${PATH}` ; do
find $dir -maxdepth 1 -type f -executable
done |
|
John ... hold my beer :)
Code: | % print $0
/bin/zsh
% print -l $^path/*(Nx) |
zsh also offers the 'commands' array:
Code: | % print ${#${commands[@]}}
1613 |
best ... khay |
|
Back to top |
|
|
|