Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Trim equery list to only show applications
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
abduct
Apprentice
Apprentice


Joined: 19 Mar 2015
Posts: 215

PostPosted: Fri Jul 20, 2018 1:02 am    Post subject: Trim equery list to only show applications Reply with quote

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
View user's profile Send private message
eccerr0r
Watchman
Watchman


Joined: 01 Jul 2004
Posts: 9677
Location: almost Mile High in the USA

PostPosted: Fri Jul 20, 2018 1:31 am    Post subject: Reply with quote

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
View user's profile Send private message
Hu
Moderator
Moderator


Joined: 06 Mar 2007
Posts: 21602

PostPosted: Fri Jul 20, 2018 1:53 am    Post subject: Reply with quote

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
View user's profile Send private message
John R. Graham
Administrator
Administrator


Joined: 08 Mar 2005
Posts: 10587
Location: Somewhere over Atlanta, Georgia

PostPosted: Fri Jul 20, 2018 2:10 am    Post subject: Reply with quote

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
View user's profile Send private message
abduct
Apprentice
Apprentice


Joined: 19 Mar 2015
Posts: 215

PostPosted: Fri Jul 20, 2018 2:48 pm    Post subject: Reply with quote

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
View user's profile Send private message
krinn
Watchman
Watchman


Joined: 02 May 2003
Posts: 7470

PostPosted: Fri Jul 20, 2018 3:15 pm    Post subject: Reply with quote

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
View user's profile Send private message
khayyam
Watchman
Watchman


Joined: 07 Jun 2012
Posts: 6227
Location: Room 101

PostPosted: Fri Jul 20, 2018 7:36 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum