Linux command to list all available commands and aliases












251















Is there a Linux command that will list all available commands and aliases for this terminal session?



As if you typed 'a' and pressed tab, but for every letter of the alphabet.
Or running 'alias' but also returning commands.



Why? I'd like to run the following and see if a command is available:



ListAllCommands | grep searchstr









share|improve this question

























  • press TAB button twice to list all commands available with environment

    – ntshetty
    Mar 8 '17 at 3:12
















251















Is there a Linux command that will list all available commands and aliases for this terminal session?



As if you typed 'a' and pressed tab, but for every letter of the alphabet.
Or running 'alias' but also returning commands.



Why? I'd like to run the following and see if a command is available:



ListAllCommands | grep searchstr









share|improve this question

























  • press TAB button twice to list all commands available with environment

    – ntshetty
    Mar 8 '17 at 3:12














251












251








251


169






Is there a Linux command that will list all available commands and aliases for this terminal session?



As if you typed 'a' and pressed tab, but for every letter of the alphabet.
Or running 'alias' but also returning commands.



Why? I'd like to run the following and see if a command is available:



ListAllCommands | grep searchstr









share|improve this question
















Is there a Linux command that will list all available commands and aliases for this terminal session?



As if you typed 'a' and pressed tab, but for every letter of the alphabet.
Or running 'alias' but also returning commands.



Why? I'd like to run the following and see if a command is available:



ListAllCommands | grep searchstr






linux command-line terminal






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jun 4 '09 at 0:53









Jonathan Leffler

570k916821034




570k916821034










asked Jun 4 '09 at 0:29









ackack

4,923184663




4,923184663













  • press TAB button twice to list all commands available with environment

    – ntshetty
    Mar 8 '17 at 3:12



















  • press TAB button twice to list all commands available with environment

    – ntshetty
    Mar 8 '17 at 3:12

















press TAB button twice to list all commands available with environment

– ntshetty
Mar 8 '17 at 3:12





press TAB button twice to list all commands available with environment

– ntshetty
Mar 8 '17 at 3:12












21 Answers
21






active

oldest

votes


















552














You can use the bash(1) built-in compgen





  • compgen -c will list all the commands you could run.


  • compgen -a will list all the aliases you could run.


  • compgen -b will list all the built-ins you could run.


  • compgen -k will list all the keywords you could run.


  • compgen -A function will list all the functions you could run.


  • compgen -A function -abck will list all the above in one go.


Check the man page for other completions you can generate.



To directly answer your question:



compgen -ac | grep searchstr


should do what yout want.






share|improve this answer


























  • Pure awesomeness! there is always so much to learn!!

    – Shankar
    Jan 21 '14 at 22:14






  • 1





    Is there an equivalent to this for csh/tcsh? Those terminals also have some sort of autocompleting function used on tab, so maybe something exists?

    – krb686
    Feb 10 '15 at 18:40






  • 1





    Instead of compgen | grep, it can be more efficient to pass the string as argument to compgen itself (if it's known to be a prefix, as implied in the question). In this case, that would be compgen -ac searchstr.

    – Toby Speight
    Jul 20 '17 at 9:01













  • Actually, ubuntu shows 'nothing appropiate' on whatis compgen and 'No manual entry' for man compgen.

    – MarAvFe
    Aug 23 '17 at 5:14






  • 1





    @MarAvFe: That's because it is a bash built-in, not a separate command with its own man page. You'll need to read the bash(1) man page, or run help compgen at a bash command line.

    – camh
    Aug 23 '17 at 20:48



















38














Add to .bashrc



function ListAllCommands
{
echo -n $PATH | xargs -d : -I {} find {} -maxdepth 1
-executable -type f -printf '%Pn' | sort -u
}


If you also want aliases, then:



function ListAllCommands
{
COMMANDS=`echo -n $PATH | xargs -d : -I {} find {} -maxdepth 1
-executable -type f -printf '%Pn'`
ALIASES=`alias | cut -d '=' -f 1`
echo "$COMMANDS"$'n'"$ALIASES" | sort -u
}





share|improve this answer


























  • This is very close but it's not including aliases. How can I append alias | cut -f1 to the results but before the sort?

    – ack
    Jun 4 '09 at 17:32






  • 1





    Why bother sorting if the only purpose is to put the output through grep anyway? Unix philosophy is to make simple tools and then chain them together if required, so leave sort out of ListAllCommands and if the user wants the output sorted they can do that.

    – danio
    Jul 21 '10 at 8:45






  • 4





    The sort is to remove duplicates.

    – Ants Aasma
    Jul 21 '10 at 20:51






  • 1





    This does not find commands that are symlinks to executables. Use the option -L on to follow symlinks to their destination. Note: -L is an option and not part of the matching expression, as such it has to be placed before the path on the command line. In this case find -L {}

    – Adaephon
    Jan 9 '14 at 14:40






  • 1





    Might want to redirect STDERR to /dev/null to suppress nonexistent directory warnings. echo -n $PATH | xargs -d : -I {} find {} -maxdepth 1 -executable -type f -printf '%Pn' 2> /dev/null | sort -u (+1 for zsh compatibility)

    – TheLonelyGhost
    May 19 '15 at 14:07



















24














There is the



type -a mycommand


command which lists all aliases and commands in $PATH where mycommand is used. Can be used to check if the command exists in several variants. Other than that... There's probably some script around that parses $PATH and all aliases, but don't know about any such script.






share|improve this answer



















  • 1





    Even if it is not an answer to the question I think it is a better solution to the problem then the call to grep. So you can do type -a foo and if foo isn't available it returns command not found or something like that. So you are able to check for a command without calling the command itself.

    – Janusz
    Jun 4 '09 at 0:41






  • 1





    Actually it is an answer to the question, as the OP asked "I'd like to run the following and see if a command is available", so the purpose is to see if a command is available and this answer clearly works.

    – lothar
    Jun 4 '09 at 2:41






  • 2





    @lothar, what if the command you're looking for is, uh, what was it, "startserver"?, "serverstart"?, "server-something-or-other"?. I know, I'll just "grep -i" for server and see if it's there. Oops. Bzzz, not with this solution. matey :-) I'm not going to vote this answer down (since it's useful even if in a limited way) but a full blown solution would take into account that grep is for regular expressions, not just fixed strings.

    – paxdiablo
    Jun 4 '09 at 3:30



















6














Use "which searchstr". Returns either the path of the binary or the alias setup if it's an alias



Edit:
If you're looking for a list of aliases, you can use:



alias -p | cut -d= -f1 | cut -d' ' -f2


Add that in to whichever PATH searching answer you like. Assumes you're using bash..






share|improve this answer

































    5














    Try this script:



    #!/bin/bash
    echo $PATH | tr : 'n' |
    while read e; do
    for i in $e/*; do
    if [[ -x "$i" && -f "$i" ]]; then
    echo $i
    fi
    done
    done





    share|improve this answer
























    • This is the only code solution so far that does it for all commands, not just to see if a given known command exists. +1.

      – paxdiablo
      Jun 4 '09 at 1:08



















    4














    The others command didn't work for me on embedded systems, because they require bash or a more complete version of xargs.



    The following commands should work on any Unix-like system.



    List by folder :



    ls $(echo $PATH | tr ':' ' ')


    List all commands by name



    ls $(echo $PATH | tr ':' ' ') | grep -v '/' | grep . | sort





    share|improve this answer

































      3














      For Mac users (find doesn't have -executable and xargs doesn't have -d):



      echo $PATH | tr ':' 'n' | xargs -I {} find {} -maxdepth 1 -type f -perm '++x'





      share|improve this answer
























      • Thanks for this. I am actually using a non-mac unix where @AntsAasma answer didn't work. This works for me on mac and my unix too. What command can I type to determine the unix version I am on, so I can reply here to help other's with my issue?

        – prismaticorb
        Feb 1 '13 at 17:29













      • I would use uname -a

        – vault
        Feb 1 '13 at 17:38











      • Linux <corporate_proprietary_build_info_here> Mon Dec 12 13:34:16 EST 2011 x86_64 x86_64 x86_64 GNU/Linux

        – prismaticorb
        Feb 1 '13 at 18:13



















      3














      It's useful to list the commands based on the keywords associated with the command.



      Use: man -k "your keyword"



      feel free to combine with:| grep "another word"



      for example, to find a text editor:
      man -k editor | grep text






      share|improve this answer































        2














        Try to press ALT-? (alt and question mark at the same time). Give it a second or two to build the list. It should work in bash.






        share|improve this answer



















        • 3





          Or try hitting Esc at the start of a blank line four times.

          – ephemient
          Jun 4 '09 at 1:55











        • That's amazingly useful, and I didn't already know it thanks :-)

          – Chris Huang-Leaver
          Jun 4 '09 at 7:27






        • 4





          Or Press Tab twice.

          – danio
          Jul 21 '10 at 8:48






        • 1





          Or Alt-! twice. Or Ctrl-x ! once. So many possibilities!

          – Victor Zamanian
          Feb 2 '13 at 23:56



















        2














        Here's a solution that gives you a list of all executables and aliases. It's also portable to systems without xargs -d (e.g. Mac OS X), and properly handles paths with spaces in them.



        #!/bin/bash
        (echo -n $PATH | tr : '' | xargs -0 -n 1 ls; alias | sed 's/alias ([^=]*)=.*/1/') | sort -u | grep "$@"


        Usage: myscript.sh [grep-options] pattern, e.g. to find all commands that begin with ls, case-insensitive, do:



        myscript -i ^ls





        share|improve this answer































          2














          shortcut method to list out all commands.
          Open terminal and press two times "tab" button.
          Thats show all commands in terminal






          share|improve this answer



















          • 1





            And you pipe that into grep exactly how?

            – Toby Speight
            Jul 20 '17 at 9:05



















          1














          You can always to the following:



          1. Hold the $PATH environment variable value.
          2. Split by ":"
          3. For earch entry:
          ls * $entry
          4. grep your command in that output.


          The shell will execute command only if they are listed in the path env var anyway.






          share|improve this answer
























          • Nice pseudo-code hehehe

            – victor hugo
            Jun 4 '09 at 0:41











          • :P .

            – OscarRyz
            Jun 4 '09 at 0:45



















          1














          it depends, by that I mean it depends on what shell you are using. here are the constraints I see:




          1. must run in the same process as your shell, to catch aliases and functions and variables that would effect the commands you can find, think PATH or EDITOR although EDITOR might be out of scope. You can have unexported variables that can effect things.

          2. it is shell specific or your going off into the kernel, /proc/pid/enviorn and friends do not have enough information


          I use ZSH so here is a zsh answer, it does the following 3 things:




          1. dumps path

          2. dumps alias names

          3. dumps functions that are in the env

          4. sorts them


          here it is:



          feed_me() {
          (alias | cut -f1 -d= ; hash -f; hash -v | cut -f 1 -d= ; typeset +f) | sort
          }


          If you use zsh this should do it.






          share|improve this answer


























          • what is the typeset +f for? I can't lookup it in man page.

            – pambda
            May 14 '17 at 3:45











          • ok I sort it out, it's for generate the function

            – pambda
            May 14 '17 at 3:47



















          1














          Alternatively, you can get a convenient list of commands coupled with quick descriptions (as long as the command has a man page, which most do):



          apropos -s 1 ''

          -s 1 returns only "section 1" manpages which are entries for executable programs.

          '' is a search for anything. (If you use an asterisk, on my system, bash throws in a search for all the files and folders in your current working directory.)


          Then you just grep it like you want.



          apropos -s 1 '' | grep xdg


          yields:



          xdg-desktop-icon (1) - command line tool for (un)installing icons to the desktop
          xdg-desktop-menu (1) - command line tool for (un)installing desktop menu items
          xdg-email (1) - command line tool for sending mail using the user's preferred e-mail composer
          xdg-icon-resource (1) - command line tool for (un)installing icon resources
          xdg-mime (1) - command line tool for querying information about file type handling and adding descriptions for new file types
          xdg-open (1) - opens a file or URL in the user's preferred application
          xdg-screensaver (1) - command line tool for controlling the screensaver
          xdg-settings (1) - get various settings from the desktop environment
          xdg-user-dir (1) - Find an XDG user dir
          xdg-user-dirs-update (1) - Update XDG user dir configuration


          The results don't appear to be sorted, so if you're looking for a long list, you can throw a | sort | into the middle, and then pipe that to a pager like less/more/most. ala:



          apropos -s 1 '' | sort | grep zip | less


          Which returns a sorted list of all commands that have "zip" in their name or their short description, and pumps that the "less" pager. (You could also replace "less" with $PAGER and use the default pager.)






          share|improve this answer

































            0














            The problem is that the tab-completion is searching your path, but all commands are not in your path.



            To find the commands in your path using bash you could do something like :



            for x in echo $PATH | cut -d":" -f1; do ls $x; done






            share|improve this answer































              0














              Here's a function you can put in your bashrc file:




              function command-search
              {
              oldIFS=${IFS}
              IFS=":"

              for p in ${PATH}
              do
              ls $p | grep $1
              done

              export IFS=${oldIFS}
              }


              Example usage:




              $ command-search gnome
              gnome-audio-profiles-properties*
              gnome-eject@
              gnome-keyring*
              gnome-keyring-daemon*
              gnome-mount*
              gnome-open*
              gnome-sound-recorder*
              gnome-text-editor@
              gnome-umount@
              gnome-volume-control*
              polkit-gnome-authorization*
              vim.gnome*
              $


              FYI: IFS is a variable that bash uses to split strings.



              Certainly there could be some better ways to do this.






              share|improve this answer































                -1














                maybe i'm misunderstanding but what if you press Escape until you got the Display All X possibilities ?






                share|improve this answer































                  -1














                  Basic commands:



                  $ touch :- user for create empty file



                  Syn:- touch filename



                  Ex: touch rama



                  $ls list of files and directories



                  $ ls –l Long listing



                  File type, permissions, link files, user(or)owner name, group name, file size, time stamp, file or dir name.



                  – regular (or) normal file



                  d directory



                  l link file



                  ls –a : show the all (including hidden files)



                  Hidden files and directories start with . (dot)



                  find more commands @ http://k2schools.com/linux-commands/






                  share|improve this answer































                    -2














                    compgen -c > list.txt && wc list.txt





                    share|improve this answer





















                    • 1





                      Consider adding a brief description of what this does or how this is supposed to work. At the very least, specify a reference link (usually the relevant man page) for following-up and understanding the proposed solution.

                      – TheCodeArtist
                      Apr 5 '15 at 3:57











                    • Using a file is not always a good option. If you do need to, then at least make it a tmp file (if security not an issue.) compgen -c > /tmp/list.txt && /tmp/wc list.txt

                      – Gary
                      Nov 5 '15 at 19:07



















                    -3














                    Why don't you just type:



                    seachstr


                    In the terminal.



                    The shell will say somehing like



                    seacrhstr: command not found 


                    EDIT:



                    Ok, I take the downvote, because the answer is stupid, I just want to know: What's wrong with this answer!!! The asker said:




                    and see if a command is available.




                    Typing the command will tell you if it is available!.



                    Probably he/she meant "with out executing the command" or "to include it in a script" but I cannot read his mind ( is not that I can't regularly it is just that he's wearing a
                    mind reading deflector )






                    share|improve this answer





















                    • 4





                      I want to know whether formathdd command exists. Oh wait, I just to run it and see. gee. Thanks :)

                      – Jeffrey Jose
                      Apr 24 '10 at 10:52






                    • 4





                      Probably safer to use 'which' to do that.

                      – danio
                      Jul 20 '10 at 15:01













                    • Given that this is Stack Overflow, not Super User, a programmatic answer would be more appropriate.

                      – Toby Speight
                      Jul 20 '17 at 9:04



















                    -5














                    in debian: ls /bin/ | grep "whatImSearchingFor"






                    share|improve this answer



















                    • 1





                      executables exist in all the directories in $PATH, not just /bin.

                      – PhrkOnLsh
                      Jun 4 '09 at 14:52











                    Your Answer






                    StackExchange.ifUsing("editor", function () {
                    StackExchange.using("externalEditor", function () {
                    StackExchange.using("snippets", function () {
                    StackExchange.snippets.init();
                    });
                    });
                    }, "code-snippets");

                    StackExchange.ready(function() {
                    var channelOptions = {
                    tags: "".split(" "),
                    id: "1"
                    };
                    initTagRenderer("".split(" "), "".split(" "), channelOptions);

                    StackExchange.using("externalEditor", function() {
                    // Have to fire editor after snippets, if snippets enabled
                    if (StackExchange.settings.snippets.snippetsEnabled) {
                    StackExchange.using("snippets", function() {
                    createEditor();
                    });
                    }
                    else {
                    createEditor();
                    }
                    });

                    function createEditor() {
                    StackExchange.prepareEditor({
                    heartbeatType: 'answer',
                    autoActivateHeartbeat: false,
                    convertImagesToLinks: true,
                    noModals: true,
                    showLowRepImageUploadWarning: true,
                    reputationToPostImages: 10,
                    bindNavPrevention: true,
                    postfix: "",
                    imageUploader: {
                    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
                    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
                    allowUrls: true
                    },
                    onDemand: true,
                    discardSelector: ".discard-answer"
                    ,immediatelyShowMarkdownHelp:true
                    });


                    }
                    });














                    draft saved

                    draft discarded


















                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f948008%2flinux-command-to-list-all-available-commands-and-aliases%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown

























                    21 Answers
                    21






                    active

                    oldest

                    votes








                    21 Answers
                    21






                    active

                    oldest

                    votes









                    active

                    oldest

                    votes






                    active

                    oldest

                    votes









                    552














                    You can use the bash(1) built-in compgen





                    • compgen -c will list all the commands you could run.


                    • compgen -a will list all the aliases you could run.


                    • compgen -b will list all the built-ins you could run.


                    • compgen -k will list all the keywords you could run.


                    • compgen -A function will list all the functions you could run.


                    • compgen -A function -abck will list all the above in one go.


                    Check the man page for other completions you can generate.



                    To directly answer your question:



                    compgen -ac | grep searchstr


                    should do what yout want.






                    share|improve this answer


























                    • Pure awesomeness! there is always so much to learn!!

                      – Shankar
                      Jan 21 '14 at 22:14






                    • 1





                      Is there an equivalent to this for csh/tcsh? Those terminals also have some sort of autocompleting function used on tab, so maybe something exists?

                      – krb686
                      Feb 10 '15 at 18:40






                    • 1





                      Instead of compgen | grep, it can be more efficient to pass the string as argument to compgen itself (if it's known to be a prefix, as implied in the question). In this case, that would be compgen -ac searchstr.

                      – Toby Speight
                      Jul 20 '17 at 9:01













                    • Actually, ubuntu shows 'nothing appropiate' on whatis compgen and 'No manual entry' for man compgen.

                      – MarAvFe
                      Aug 23 '17 at 5:14






                    • 1





                      @MarAvFe: That's because it is a bash built-in, not a separate command with its own man page. You'll need to read the bash(1) man page, or run help compgen at a bash command line.

                      – camh
                      Aug 23 '17 at 20:48
















                    552














                    You can use the bash(1) built-in compgen





                    • compgen -c will list all the commands you could run.


                    • compgen -a will list all the aliases you could run.


                    • compgen -b will list all the built-ins you could run.


                    • compgen -k will list all the keywords you could run.


                    • compgen -A function will list all the functions you could run.


                    • compgen -A function -abck will list all the above in one go.


                    Check the man page for other completions you can generate.



                    To directly answer your question:



                    compgen -ac | grep searchstr


                    should do what yout want.






                    share|improve this answer


























                    • Pure awesomeness! there is always so much to learn!!

                      – Shankar
                      Jan 21 '14 at 22:14






                    • 1





                      Is there an equivalent to this for csh/tcsh? Those terminals also have some sort of autocompleting function used on tab, so maybe something exists?

                      – krb686
                      Feb 10 '15 at 18:40






                    • 1





                      Instead of compgen | grep, it can be more efficient to pass the string as argument to compgen itself (if it's known to be a prefix, as implied in the question). In this case, that would be compgen -ac searchstr.

                      – Toby Speight
                      Jul 20 '17 at 9:01













                    • Actually, ubuntu shows 'nothing appropiate' on whatis compgen and 'No manual entry' for man compgen.

                      – MarAvFe
                      Aug 23 '17 at 5:14






                    • 1





                      @MarAvFe: That's because it is a bash built-in, not a separate command with its own man page. You'll need to read the bash(1) man page, or run help compgen at a bash command line.

                      – camh
                      Aug 23 '17 at 20:48














                    552












                    552








                    552







                    You can use the bash(1) built-in compgen





                    • compgen -c will list all the commands you could run.


                    • compgen -a will list all the aliases you could run.


                    • compgen -b will list all the built-ins you could run.


                    • compgen -k will list all the keywords you could run.


                    • compgen -A function will list all the functions you could run.


                    • compgen -A function -abck will list all the above in one go.


                    Check the man page for other completions you can generate.



                    To directly answer your question:



                    compgen -ac | grep searchstr


                    should do what yout want.






                    share|improve this answer















                    You can use the bash(1) built-in compgen





                    • compgen -c will list all the commands you could run.


                    • compgen -a will list all the aliases you could run.


                    • compgen -b will list all the built-ins you could run.


                    • compgen -k will list all the keywords you could run.


                    • compgen -A function will list all the functions you could run.


                    • compgen -A function -abck will list all the above in one go.


                    Check the man page for other completions you can generate.



                    To directly answer your question:



                    compgen -ac | grep searchstr


                    should do what yout want.







                    share|improve this answer














                    share|improve this answer



                    share|improve this answer








                    edited May 25 '11 at 1:13

























                    answered Jun 4 '09 at 7:07









                    camhcamh

                    28.9k105261




                    28.9k105261













                    • Pure awesomeness! there is always so much to learn!!

                      – Shankar
                      Jan 21 '14 at 22:14






                    • 1





                      Is there an equivalent to this for csh/tcsh? Those terminals also have some sort of autocompleting function used on tab, so maybe something exists?

                      – krb686
                      Feb 10 '15 at 18:40






                    • 1





                      Instead of compgen | grep, it can be more efficient to pass the string as argument to compgen itself (if it's known to be a prefix, as implied in the question). In this case, that would be compgen -ac searchstr.

                      – Toby Speight
                      Jul 20 '17 at 9:01













                    • Actually, ubuntu shows 'nothing appropiate' on whatis compgen and 'No manual entry' for man compgen.

                      – MarAvFe
                      Aug 23 '17 at 5:14






                    • 1





                      @MarAvFe: That's because it is a bash built-in, not a separate command with its own man page. You'll need to read the bash(1) man page, or run help compgen at a bash command line.

                      – camh
                      Aug 23 '17 at 20:48



















                    • Pure awesomeness! there is always so much to learn!!

                      – Shankar
                      Jan 21 '14 at 22:14






                    • 1





                      Is there an equivalent to this for csh/tcsh? Those terminals also have some sort of autocompleting function used on tab, so maybe something exists?

                      – krb686
                      Feb 10 '15 at 18:40






                    • 1





                      Instead of compgen | grep, it can be more efficient to pass the string as argument to compgen itself (if it's known to be a prefix, as implied in the question). In this case, that would be compgen -ac searchstr.

                      – Toby Speight
                      Jul 20 '17 at 9:01













                    • Actually, ubuntu shows 'nothing appropiate' on whatis compgen and 'No manual entry' for man compgen.

                      – MarAvFe
                      Aug 23 '17 at 5:14






                    • 1





                      @MarAvFe: That's because it is a bash built-in, not a separate command with its own man page. You'll need to read the bash(1) man page, or run help compgen at a bash command line.

                      – camh
                      Aug 23 '17 at 20:48

















                    Pure awesomeness! there is always so much to learn!!

                    – Shankar
                    Jan 21 '14 at 22:14





                    Pure awesomeness! there is always so much to learn!!

                    – Shankar
                    Jan 21 '14 at 22:14




                    1




                    1





                    Is there an equivalent to this for csh/tcsh? Those terminals also have some sort of autocompleting function used on tab, so maybe something exists?

                    – krb686
                    Feb 10 '15 at 18:40





                    Is there an equivalent to this for csh/tcsh? Those terminals also have some sort of autocompleting function used on tab, so maybe something exists?

                    – krb686
                    Feb 10 '15 at 18:40




                    1




                    1





                    Instead of compgen | grep, it can be more efficient to pass the string as argument to compgen itself (if it's known to be a prefix, as implied in the question). In this case, that would be compgen -ac searchstr.

                    – Toby Speight
                    Jul 20 '17 at 9:01







                    Instead of compgen | grep, it can be more efficient to pass the string as argument to compgen itself (if it's known to be a prefix, as implied in the question). In this case, that would be compgen -ac searchstr.

                    – Toby Speight
                    Jul 20 '17 at 9:01















                    Actually, ubuntu shows 'nothing appropiate' on whatis compgen and 'No manual entry' for man compgen.

                    – MarAvFe
                    Aug 23 '17 at 5:14





                    Actually, ubuntu shows 'nothing appropiate' on whatis compgen and 'No manual entry' for man compgen.

                    – MarAvFe
                    Aug 23 '17 at 5:14




                    1




                    1





                    @MarAvFe: That's because it is a bash built-in, not a separate command with its own man page. You'll need to read the bash(1) man page, or run help compgen at a bash command line.

                    – camh
                    Aug 23 '17 at 20:48





                    @MarAvFe: That's because it is a bash built-in, not a separate command with its own man page. You'll need to read the bash(1) man page, or run help compgen at a bash command line.

                    – camh
                    Aug 23 '17 at 20:48













                    38














                    Add to .bashrc



                    function ListAllCommands
                    {
                    echo -n $PATH | xargs -d : -I {} find {} -maxdepth 1
                    -executable -type f -printf '%Pn' | sort -u
                    }


                    If you also want aliases, then:



                    function ListAllCommands
                    {
                    COMMANDS=`echo -n $PATH | xargs -d : -I {} find {} -maxdepth 1
                    -executable -type f -printf '%Pn'`
                    ALIASES=`alias | cut -d '=' -f 1`
                    echo "$COMMANDS"$'n'"$ALIASES" | sort -u
                    }





                    share|improve this answer


























                    • This is very close but it's not including aliases. How can I append alias | cut -f1 to the results but before the sort?

                      – ack
                      Jun 4 '09 at 17:32






                    • 1





                      Why bother sorting if the only purpose is to put the output through grep anyway? Unix philosophy is to make simple tools and then chain them together if required, so leave sort out of ListAllCommands and if the user wants the output sorted they can do that.

                      – danio
                      Jul 21 '10 at 8:45






                    • 4





                      The sort is to remove duplicates.

                      – Ants Aasma
                      Jul 21 '10 at 20:51






                    • 1





                      This does not find commands that are symlinks to executables. Use the option -L on to follow symlinks to their destination. Note: -L is an option and not part of the matching expression, as such it has to be placed before the path on the command line. In this case find -L {}

                      – Adaephon
                      Jan 9 '14 at 14:40






                    • 1





                      Might want to redirect STDERR to /dev/null to suppress nonexistent directory warnings. echo -n $PATH | xargs -d : -I {} find {} -maxdepth 1 -executable -type f -printf '%Pn' 2> /dev/null | sort -u (+1 for zsh compatibility)

                      – TheLonelyGhost
                      May 19 '15 at 14:07
















                    38














                    Add to .bashrc



                    function ListAllCommands
                    {
                    echo -n $PATH | xargs -d : -I {} find {} -maxdepth 1
                    -executable -type f -printf '%Pn' | sort -u
                    }


                    If you also want aliases, then:



                    function ListAllCommands
                    {
                    COMMANDS=`echo -n $PATH | xargs -d : -I {} find {} -maxdepth 1
                    -executable -type f -printf '%Pn'`
                    ALIASES=`alias | cut -d '=' -f 1`
                    echo "$COMMANDS"$'n'"$ALIASES" | sort -u
                    }





                    share|improve this answer


























                    • This is very close but it's not including aliases. How can I append alias | cut -f1 to the results but before the sort?

                      – ack
                      Jun 4 '09 at 17:32






                    • 1





                      Why bother sorting if the only purpose is to put the output through grep anyway? Unix philosophy is to make simple tools and then chain them together if required, so leave sort out of ListAllCommands and if the user wants the output sorted they can do that.

                      – danio
                      Jul 21 '10 at 8:45






                    • 4





                      The sort is to remove duplicates.

                      – Ants Aasma
                      Jul 21 '10 at 20:51






                    • 1





                      This does not find commands that are symlinks to executables. Use the option -L on to follow symlinks to their destination. Note: -L is an option and not part of the matching expression, as such it has to be placed before the path on the command line. In this case find -L {}

                      – Adaephon
                      Jan 9 '14 at 14:40






                    • 1





                      Might want to redirect STDERR to /dev/null to suppress nonexistent directory warnings. echo -n $PATH | xargs -d : -I {} find {} -maxdepth 1 -executable -type f -printf '%Pn' 2> /dev/null | sort -u (+1 for zsh compatibility)

                      – TheLonelyGhost
                      May 19 '15 at 14:07














                    38












                    38








                    38







                    Add to .bashrc



                    function ListAllCommands
                    {
                    echo -n $PATH | xargs -d : -I {} find {} -maxdepth 1
                    -executable -type f -printf '%Pn' | sort -u
                    }


                    If you also want aliases, then:



                    function ListAllCommands
                    {
                    COMMANDS=`echo -n $PATH | xargs -d : -I {} find {} -maxdepth 1
                    -executable -type f -printf '%Pn'`
                    ALIASES=`alias | cut -d '=' -f 1`
                    echo "$COMMANDS"$'n'"$ALIASES" | sort -u
                    }





                    share|improve this answer















                    Add to .bashrc



                    function ListAllCommands
                    {
                    echo -n $PATH | xargs -d : -I {} find {} -maxdepth 1
                    -executable -type f -printf '%Pn' | sort -u
                    }


                    If you also want aliases, then:



                    function ListAllCommands
                    {
                    COMMANDS=`echo -n $PATH | xargs -d : -I {} find {} -maxdepth 1
                    -executable -type f -printf '%Pn'`
                    ALIASES=`alias | cut -d '=' -f 1`
                    echo "$COMMANDS"$'n'"$ALIASES" | sort -u
                    }






                    share|improve this answer














                    share|improve this answer



                    share|improve this answer








                    edited Jun 4 '09 at 20:32

























                    answered Jun 4 '09 at 1:12









                    Ants AasmaAnts Aasma

                    39.8k67484




                    39.8k67484













                    • This is very close but it's not including aliases. How can I append alias | cut -f1 to the results but before the sort?

                      – ack
                      Jun 4 '09 at 17:32






                    • 1





                      Why bother sorting if the only purpose is to put the output through grep anyway? Unix philosophy is to make simple tools and then chain them together if required, so leave sort out of ListAllCommands and if the user wants the output sorted they can do that.

                      – danio
                      Jul 21 '10 at 8:45






                    • 4





                      The sort is to remove duplicates.

                      – Ants Aasma
                      Jul 21 '10 at 20:51






                    • 1





                      This does not find commands that are symlinks to executables. Use the option -L on to follow symlinks to their destination. Note: -L is an option and not part of the matching expression, as such it has to be placed before the path on the command line. In this case find -L {}

                      – Adaephon
                      Jan 9 '14 at 14:40






                    • 1





                      Might want to redirect STDERR to /dev/null to suppress nonexistent directory warnings. echo -n $PATH | xargs -d : -I {} find {} -maxdepth 1 -executable -type f -printf '%Pn' 2> /dev/null | sort -u (+1 for zsh compatibility)

                      – TheLonelyGhost
                      May 19 '15 at 14:07



















                    • This is very close but it's not including aliases. How can I append alias | cut -f1 to the results but before the sort?

                      – ack
                      Jun 4 '09 at 17:32






                    • 1





                      Why bother sorting if the only purpose is to put the output through grep anyway? Unix philosophy is to make simple tools and then chain them together if required, so leave sort out of ListAllCommands and if the user wants the output sorted they can do that.

                      – danio
                      Jul 21 '10 at 8:45






                    • 4





                      The sort is to remove duplicates.

                      – Ants Aasma
                      Jul 21 '10 at 20:51






                    • 1





                      This does not find commands that are symlinks to executables. Use the option -L on to follow symlinks to their destination. Note: -L is an option and not part of the matching expression, as such it has to be placed before the path on the command line. In this case find -L {}

                      – Adaephon
                      Jan 9 '14 at 14:40






                    • 1





                      Might want to redirect STDERR to /dev/null to suppress nonexistent directory warnings. echo -n $PATH | xargs -d : -I {} find {} -maxdepth 1 -executable -type f -printf '%Pn' 2> /dev/null | sort -u (+1 for zsh compatibility)

                      – TheLonelyGhost
                      May 19 '15 at 14:07

















                    This is very close but it's not including aliases. How can I append alias | cut -f1 to the results but before the sort?

                    – ack
                    Jun 4 '09 at 17:32





                    This is very close but it's not including aliases. How can I append alias | cut -f1 to the results but before the sort?

                    – ack
                    Jun 4 '09 at 17:32




                    1




                    1





                    Why bother sorting if the only purpose is to put the output through grep anyway? Unix philosophy is to make simple tools and then chain them together if required, so leave sort out of ListAllCommands and if the user wants the output sorted they can do that.

                    – danio
                    Jul 21 '10 at 8:45





                    Why bother sorting if the only purpose is to put the output through grep anyway? Unix philosophy is to make simple tools and then chain them together if required, so leave sort out of ListAllCommands and if the user wants the output sorted they can do that.

                    – danio
                    Jul 21 '10 at 8:45




                    4




                    4





                    The sort is to remove duplicates.

                    – Ants Aasma
                    Jul 21 '10 at 20:51





                    The sort is to remove duplicates.

                    – Ants Aasma
                    Jul 21 '10 at 20:51




                    1




                    1





                    This does not find commands that are symlinks to executables. Use the option -L on to follow symlinks to their destination. Note: -L is an option and not part of the matching expression, as such it has to be placed before the path on the command line. In this case find -L {}

                    – Adaephon
                    Jan 9 '14 at 14:40





                    This does not find commands that are symlinks to executables. Use the option -L on to follow symlinks to their destination. Note: -L is an option and not part of the matching expression, as such it has to be placed before the path on the command line. In this case find -L {}

                    – Adaephon
                    Jan 9 '14 at 14:40




                    1




                    1





                    Might want to redirect STDERR to /dev/null to suppress nonexistent directory warnings. echo -n $PATH | xargs -d : -I {} find {} -maxdepth 1 -executable -type f -printf '%Pn' 2> /dev/null | sort -u (+1 for zsh compatibility)

                    – TheLonelyGhost
                    May 19 '15 at 14:07





                    Might want to redirect STDERR to /dev/null to suppress nonexistent directory warnings. echo -n $PATH | xargs -d : -I {} find {} -maxdepth 1 -executable -type f -printf '%Pn' 2> /dev/null | sort -u (+1 for zsh compatibility)

                    – TheLonelyGhost
                    May 19 '15 at 14:07











                    24














                    There is the



                    type -a mycommand


                    command which lists all aliases and commands in $PATH where mycommand is used. Can be used to check if the command exists in several variants. Other than that... There's probably some script around that parses $PATH and all aliases, but don't know about any such script.






                    share|improve this answer



















                    • 1





                      Even if it is not an answer to the question I think it is a better solution to the problem then the call to grep. So you can do type -a foo and if foo isn't available it returns command not found or something like that. So you are able to check for a command without calling the command itself.

                      – Janusz
                      Jun 4 '09 at 0:41






                    • 1





                      Actually it is an answer to the question, as the OP asked "I'd like to run the following and see if a command is available", so the purpose is to see if a command is available and this answer clearly works.

                      – lothar
                      Jun 4 '09 at 2:41






                    • 2





                      @lothar, what if the command you're looking for is, uh, what was it, "startserver"?, "serverstart"?, "server-something-or-other"?. I know, I'll just "grep -i" for server and see if it's there. Oops. Bzzz, not with this solution. matey :-) I'm not going to vote this answer down (since it's useful even if in a limited way) but a full blown solution would take into account that grep is for regular expressions, not just fixed strings.

                      – paxdiablo
                      Jun 4 '09 at 3:30
















                    24














                    There is the



                    type -a mycommand


                    command which lists all aliases and commands in $PATH where mycommand is used. Can be used to check if the command exists in several variants. Other than that... There's probably some script around that parses $PATH and all aliases, but don't know about any such script.






                    share|improve this answer



















                    • 1





                      Even if it is not an answer to the question I think it is a better solution to the problem then the call to grep. So you can do type -a foo and if foo isn't available it returns command not found or something like that. So you are able to check for a command without calling the command itself.

                      – Janusz
                      Jun 4 '09 at 0:41






                    • 1





                      Actually it is an answer to the question, as the OP asked "I'd like to run the following and see if a command is available", so the purpose is to see if a command is available and this answer clearly works.

                      – lothar
                      Jun 4 '09 at 2:41






                    • 2





                      @lothar, what if the command you're looking for is, uh, what was it, "startserver"?, "serverstart"?, "server-something-or-other"?. I know, I'll just "grep -i" for server and see if it's there. Oops. Bzzz, not with this solution. matey :-) I'm not going to vote this answer down (since it's useful even if in a limited way) but a full blown solution would take into account that grep is for regular expressions, not just fixed strings.

                      – paxdiablo
                      Jun 4 '09 at 3:30














                    24












                    24








                    24







                    There is the



                    type -a mycommand


                    command which lists all aliases and commands in $PATH where mycommand is used. Can be used to check if the command exists in several variants. Other than that... There's probably some script around that parses $PATH and all aliases, but don't know about any such script.






                    share|improve this answer













                    There is the



                    type -a mycommand


                    command which lists all aliases and commands in $PATH where mycommand is used. Can be used to check if the command exists in several variants. Other than that... There's probably some script around that parses $PATH and all aliases, but don't know about any such script.







                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered Jun 4 '09 at 0:36









                    sunny256sunny256

                    7,15821822




                    7,15821822








                    • 1





                      Even if it is not an answer to the question I think it is a better solution to the problem then the call to grep. So you can do type -a foo and if foo isn't available it returns command not found or something like that. So you are able to check for a command without calling the command itself.

                      – Janusz
                      Jun 4 '09 at 0:41






                    • 1





                      Actually it is an answer to the question, as the OP asked "I'd like to run the following and see if a command is available", so the purpose is to see if a command is available and this answer clearly works.

                      – lothar
                      Jun 4 '09 at 2:41






                    • 2





                      @lothar, what if the command you're looking for is, uh, what was it, "startserver"?, "serverstart"?, "server-something-or-other"?. I know, I'll just "grep -i" for server and see if it's there. Oops. Bzzz, not with this solution. matey :-) I'm not going to vote this answer down (since it's useful even if in a limited way) but a full blown solution would take into account that grep is for regular expressions, not just fixed strings.

                      – paxdiablo
                      Jun 4 '09 at 3:30














                    • 1





                      Even if it is not an answer to the question I think it is a better solution to the problem then the call to grep. So you can do type -a foo and if foo isn't available it returns command not found or something like that. So you are able to check for a command without calling the command itself.

                      – Janusz
                      Jun 4 '09 at 0:41






                    • 1





                      Actually it is an answer to the question, as the OP asked "I'd like to run the following and see if a command is available", so the purpose is to see if a command is available and this answer clearly works.

                      – lothar
                      Jun 4 '09 at 2:41






                    • 2





                      @lothar, what if the command you're looking for is, uh, what was it, "startserver"?, "serverstart"?, "server-something-or-other"?. I know, I'll just "grep -i" for server and see if it's there. Oops. Bzzz, not with this solution. matey :-) I'm not going to vote this answer down (since it's useful even if in a limited way) but a full blown solution would take into account that grep is for regular expressions, not just fixed strings.

                      – paxdiablo
                      Jun 4 '09 at 3:30








                    1




                    1





                    Even if it is not an answer to the question I think it is a better solution to the problem then the call to grep. So you can do type -a foo and if foo isn't available it returns command not found or something like that. So you are able to check for a command without calling the command itself.

                    – Janusz
                    Jun 4 '09 at 0:41





                    Even if it is not an answer to the question I think it is a better solution to the problem then the call to grep. So you can do type -a foo and if foo isn't available it returns command not found or something like that. So you are able to check for a command without calling the command itself.

                    – Janusz
                    Jun 4 '09 at 0:41




                    1




                    1





                    Actually it is an answer to the question, as the OP asked "I'd like to run the following and see if a command is available", so the purpose is to see if a command is available and this answer clearly works.

                    – lothar
                    Jun 4 '09 at 2:41





                    Actually it is an answer to the question, as the OP asked "I'd like to run the following and see if a command is available", so the purpose is to see if a command is available and this answer clearly works.

                    – lothar
                    Jun 4 '09 at 2:41




                    2




                    2





                    @lothar, what if the command you're looking for is, uh, what was it, "startserver"?, "serverstart"?, "server-something-or-other"?. I know, I'll just "grep -i" for server and see if it's there. Oops. Bzzz, not with this solution. matey :-) I'm not going to vote this answer down (since it's useful even if in a limited way) but a full blown solution would take into account that grep is for regular expressions, not just fixed strings.

                    – paxdiablo
                    Jun 4 '09 at 3:30





                    @lothar, what if the command you're looking for is, uh, what was it, "startserver"?, "serverstart"?, "server-something-or-other"?. I know, I'll just "grep -i" for server and see if it's there. Oops. Bzzz, not with this solution. matey :-) I'm not going to vote this answer down (since it's useful even if in a limited way) but a full blown solution would take into account that grep is for regular expressions, not just fixed strings.

                    – paxdiablo
                    Jun 4 '09 at 3:30











                    6














                    Use "which searchstr". Returns either the path of the binary or the alias setup if it's an alias



                    Edit:
                    If you're looking for a list of aliases, you can use:



                    alias -p | cut -d= -f1 | cut -d' ' -f2


                    Add that in to whichever PATH searching answer you like. Assumes you're using bash..






                    share|improve this answer






























                      6














                      Use "which searchstr". Returns either the path of the binary or the alias setup if it's an alias



                      Edit:
                      If you're looking for a list of aliases, you can use:



                      alias -p | cut -d= -f1 | cut -d' ' -f2


                      Add that in to whichever PATH searching answer you like. Assumes you're using bash..






                      share|improve this answer




























                        6












                        6








                        6







                        Use "which searchstr". Returns either the path of the binary or the alias setup if it's an alias



                        Edit:
                        If you're looking for a list of aliases, you can use:



                        alias -p | cut -d= -f1 | cut -d' ' -f2


                        Add that in to whichever PATH searching answer you like. Assumes you're using bash..






                        share|improve this answer















                        Use "which searchstr". Returns either the path of the binary or the alias setup if it's an alias



                        Edit:
                        If you're looking for a list of aliases, you can use:



                        alias -p | cut -d= -f1 | cut -d' ' -f2


                        Add that in to whichever PATH searching answer you like. Assumes you're using bash..







                        share|improve this answer














                        share|improve this answer



                        share|improve this answer








                        edited Jun 4 '09 at 1:28

























                        answered Jun 4 '09 at 0:42









                        AaronAaron

                        7611720




                        7611720























                            5














                            Try this script:



                            #!/bin/bash
                            echo $PATH | tr : 'n' |
                            while read e; do
                            for i in $e/*; do
                            if [[ -x "$i" && -f "$i" ]]; then
                            echo $i
                            fi
                            done
                            done





                            share|improve this answer
























                            • This is the only code solution so far that does it for all commands, not just to see if a given known command exists. +1.

                              – paxdiablo
                              Jun 4 '09 at 1:08
















                            5














                            Try this script:



                            #!/bin/bash
                            echo $PATH | tr : 'n' |
                            while read e; do
                            for i in $e/*; do
                            if [[ -x "$i" && -f "$i" ]]; then
                            echo $i
                            fi
                            done
                            done





                            share|improve this answer
























                            • This is the only code solution so far that does it for all commands, not just to see if a given known command exists. +1.

                              – paxdiablo
                              Jun 4 '09 at 1:08














                            5












                            5








                            5







                            Try this script:



                            #!/bin/bash
                            echo $PATH | tr : 'n' |
                            while read e; do
                            for i in $e/*; do
                            if [[ -x "$i" && -f "$i" ]]; then
                            echo $i
                            fi
                            done
                            done





                            share|improve this answer













                            Try this script:



                            #!/bin/bash
                            echo $PATH | tr : 'n' |
                            while read e; do
                            for i in $e/*; do
                            if [[ -x "$i" && -f "$i" ]]; then
                            echo $i
                            fi
                            done
                            done






                            share|improve this answer












                            share|improve this answer



                            share|improve this answer










                            answered Jun 4 '09 at 0:53









                            victor hugovictor hugo

                            29.6k105975




                            29.6k105975













                            • This is the only code solution so far that does it for all commands, not just to see if a given known command exists. +1.

                              – paxdiablo
                              Jun 4 '09 at 1:08



















                            • This is the only code solution so far that does it for all commands, not just to see if a given known command exists. +1.

                              – paxdiablo
                              Jun 4 '09 at 1:08

















                            This is the only code solution so far that does it for all commands, not just to see if a given known command exists. +1.

                            – paxdiablo
                            Jun 4 '09 at 1:08





                            This is the only code solution so far that does it for all commands, not just to see if a given known command exists. +1.

                            – paxdiablo
                            Jun 4 '09 at 1:08











                            4














                            The others command didn't work for me on embedded systems, because they require bash or a more complete version of xargs.



                            The following commands should work on any Unix-like system.



                            List by folder :



                            ls $(echo $PATH | tr ':' ' ')


                            List all commands by name



                            ls $(echo $PATH | tr ':' ' ') | grep -v '/' | grep . | sort





                            share|improve this answer






























                              4














                              The others command didn't work for me on embedded systems, because they require bash or a more complete version of xargs.



                              The following commands should work on any Unix-like system.



                              List by folder :



                              ls $(echo $PATH | tr ':' ' ')


                              List all commands by name



                              ls $(echo $PATH | tr ':' ' ') | grep -v '/' | grep . | sort





                              share|improve this answer




























                                4












                                4








                                4







                                The others command didn't work for me on embedded systems, because they require bash or a more complete version of xargs.



                                The following commands should work on any Unix-like system.



                                List by folder :



                                ls $(echo $PATH | tr ':' ' ')


                                List all commands by name



                                ls $(echo $PATH | tr ':' ' ') | grep -v '/' | grep . | sort





                                share|improve this answer















                                The others command didn't work for me on embedded systems, because they require bash or a more complete version of xargs.



                                The following commands should work on any Unix-like system.



                                List by folder :



                                ls $(echo $PATH | tr ':' ' ')


                                List all commands by name



                                ls $(echo $PATH | tr ':' ' ') | grep -v '/' | grep . | sort






                                share|improve this answer














                                share|improve this answer



                                share|improve this answer








                                edited Nov 15 '18 at 14:09

























                                answered Sep 7 '17 at 9:11









                                Olivier LasneOlivier Lasne

                                30119




                                30119























                                    3














                                    For Mac users (find doesn't have -executable and xargs doesn't have -d):



                                    echo $PATH | tr ':' 'n' | xargs -I {} find {} -maxdepth 1 -type f -perm '++x'





                                    share|improve this answer
























                                    • Thanks for this. I am actually using a non-mac unix where @AntsAasma answer didn't work. This works for me on mac and my unix too. What command can I type to determine the unix version I am on, so I can reply here to help other's with my issue?

                                      – prismaticorb
                                      Feb 1 '13 at 17:29













                                    • I would use uname -a

                                      – vault
                                      Feb 1 '13 at 17:38











                                    • Linux <corporate_proprietary_build_info_here> Mon Dec 12 13:34:16 EST 2011 x86_64 x86_64 x86_64 GNU/Linux

                                      – prismaticorb
                                      Feb 1 '13 at 18:13
















                                    3














                                    For Mac users (find doesn't have -executable and xargs doesn't have -d):



                                    echo $PATH | tr ':' 'n' | xargs -I {} find {} -maxdepth 1 -type f -perm '++x'





                                    share|improve this answer
























                                    • Thanks for this. I am actually using a non-mac unix where @AntsAasma answer didn't work. This works for me on mac and my unix too. What command can I type to determine the unix version I am on, so I can reply here to help other's with my issue?

                                      – prismaticorb
                                      Feb 1 '13 at 17:29













                                    • I would use uname -a

                                      – vault
                                      Feb 1 '13 at 17:38











                                    • Linux <corporate_proprietary_build_info_here> Mon Dec 12 13:34:16 EST 2011 x86_64 x86_64 x86_64 GNU/Linux

                                      – prismaticorb
                                      Feb 1 '13 at 18:13














                                    3












                                    3








                                    3







                                    For Mac users (find doesn't have -executable and xargs doesn't have -d):



                                    echo $PATH | tr ':' 'n' | xargs -I {} find {} -maxdepth 1 -type f -perm '++x'





                                    share|improve this answer













                                    For Mac users (find doesn't have -executable and xargs doesn't have -d):



                                    echo $PATH | tr ':' 'n' | xargs -I {} find {} -maxdepth 1 -type f -perm '++x'






                                    share|improve this answer












                                    share|improve this answer



                                    share|improve this answer










                                    answered Oct 24 '12 at 15:41









                                    vaultvault

                                    2,2962735




                                    2,2962735













                                    • Thanks for this. I am actually using a non-mac unix where @AntsAasma answer didn't work. This works for me on mac and my unix too. What command can I type to determine the unix version I am on, so I can reply here to help other's with my issue?

                                      – prismaticorb
                                      Feb 1 '13 at 17:29













                                    • I would use uname -a

                                      – vault
                                      Feb 1 '13 at 17:38











                                    • Linux <corporate_proprietary_build_info_here> Mon Dec 12 13:34:16 EST 2011 x86_64 x86_64 x86_64 GNU/Linux

                                      – prismaticorb
                                      Feb 1 '13 at 18:13



















                                    • Thanks for this. I am actually using a non-mac unix where @AntsAasma answer didn't work. This works for me on mac and my unix too. What command can I type to determine the unix version I am on, so I can reply here to help other's with my issue?

                                      – prismaticorb
                                      Feb 1 '13 at 17:29













                                    • I would use uname -a

                                      – vault
                                      Feb 1 '13 at 17:38











                                    • Linux <corporate_proprietary_build_info_here> Mon Dec 12 13:34:16 EST 2011 x86_64 x86_64 x86_64 GNU/Linux

                                      – prismaticorb
                                      Feb 1 '13 at 18:13

















                                    Thanks for this. I am actually using a non-mac unix where @AntsAasma answer didn't work. This works for me on mac and my unix too. What command can I type to determine the unix version I am on, so I can reply here to help other's with my issue?

                                    – prismaticorb
                                    Feb 1 '13 at 17:29







                                    Thanks for this. I am actually using a non-mac unix where @AntsAasma answer didn't work. This works for me on mac and my unix too. What command can I type to determine the unix version I am on, so I can reply here to help other's with my issue?

                                    – prismaticorb
                                    Feb 1 '13 at 17:29















                                    I would use uname -a

                                    – vault
                                    Feb 1 '13 at 17:38





                                    I would use uname -a

                                    – vault
                                    Feb 1 '13 at 17:38













                                    Linux <corporate_proprietary_build_info_here> Mon Dec 12 13:34:16 EST 2011 x86_64 x86_64 x86_64 GNU/Linux

                                    – prismaticorb
                                    Feb 1 '13 at 18:13





                                    Linux <corporate_proprietary_build_info_here> Mon Dec 12 13:34:16 EST 2011 x86_64 x86_64 x86_64 GNU/Linux

                                    – prismaticorb
                                    Feb 1 '13 at 18:13











                                    3














                                    It's useful to list the commands based on the keywords associated with the command.



                                    Use: man -k "your keyword"



                                    feel free to combine with:| grep "another word"



                                    for example, to find a text editor:
                                    man -k editor | grep text






                                    share|improve this answer




























                                      3














                                      It's useful to list the commands based on the keywords associated with the command.



                                      Use: man -k "your keyword"



                                      feel free to combine with:| grep "another word"



                                      for example, to find a text editor:
                                      man -k editor | grep text






                                      share|improve this answer


























                                        3












                                        3








                                        3







                                        It's useful to list the commands based on the keywords associated with the command.



                                        Use: man -k "your keyword"



                                        feel free to combine with:| grep "another word"



                                        for example, to find a text editor:
                                        man -k editor | grep text






                                        share|improve this answer













                                        It's useful to list the commands based on the keywords associated with the command.



                                        Use: man -k "your keyword"



                                        feel free to combine with:| grep "another word"



                                        for example, to find a text editor:
                                        man -k editor | grep text







                                        share|improve this answer












                                        share|improve this answer



                                        share|improve this answer










                                        answered Nov 7 '14 at 17:46









                                        FinchFinch

                                        311




                                        311























                                            2














                                            Try to press ALT-? (alt and question mark at the same time). Give it a second or two to build the list. It should work in bash.






                                            share|improve this answer



















                                            • 3





                                              Or try hitting Esc at the start of a blank line four times.

                                              – ephemient
                                              Jun 4 '09 at 1:55











                                            • That's amazingly useful, and I didn't already know it thanks :-)

                                              – Chris Huang-Leaver
                                              Jun 4 '09 at 7:27






                                            • 4





                                              Or Press Tab twice.

                                              – danio
                                              Jul 21 '10 at 8:48






                                            • 1





                                              Or Alt-! twice. Or Ctrl-x ! once. So many possibilities!

                                              – Victor Zamanian
                                              Feb 2 '13 at 23:56
















                                            2














                                            Try to press ALT-? (alt and question mark at the same time). Give it a second or two to build the list. It should work in bash.






                                            share|improve this answer



















                                            • 3





                                              Or try hitting Esc at the start of a blank line four times.

                                              – ephemient
                                              Jun 4 '09 at 1:55











                                            • That's amazingly useful, and I didn't already know it thanks :-)

                                              – Chris Huang-Leaver
                                              Jun 4 '09 at 7:27






                                            • 4





                                              Or Press Tab twice.

                                              – danio
                                              Jul 21 '10 at 8:48






                                            • 1





                                              Or Alt-! twice. Or Ctrl-x ! once. So many possibilities!

                                              – Victor Zamanian
                                              Feb 2 '13 at 23:56














                                            2












                                            2








                                            2







                                            Try to press ALT-? (alt and question mark at the same time). Give it a second or two to build the list. It should work in bash.






                                            share|improve this answer













                                            Try to press ALT-? (alt and question mark at the same time). Give it a second or two to build the list. It should work in bash.







                                            share|improve this answer












                                            share|improve this answer



                                            share|improve this answer










                                            answered Jun 4 '09 at 0:50









                                            Igor KrivokonIgor Krivokon

                                            8,99112740




                                            8,99112740








                                            • 3





                                              Or try hitting Esc at the start of a blank line four times.

                                              – ephemient
                                              Jun 4 '09 at 1:55











                                            • That's amazingly useful, and I didn't already know it thanks :-)

                                              – Chris Huang-Leaver
                                              Jun 4 '09 at 7:27






                                            • 4





                                              Or Press Tab twice.

                                              – danio
                                              Jul 21 '10 at 8:48






                                            • 1





                                              Or Alt-! twice. Or Ctrl-x ! once. So many possibilities!

                                              – Victor Zamanian
                                              Feb 2 '13 at 23:56














                                            • 3





                                              Or try hitting Esc at the start of a blank line four times.

                                              – ephemient
                                              Jun 4 '09 at 1:55











                                            • That's amazingly useful, and I didn't already know it thanks :-)

                                              – Chris Huang-Leaver
                                              Jun 4 '09 at 7:27






                                            • 4





                                              Or Press Tab twice.

                                              – danio
                                              Jul 21 '10 at 8:48






                                            • 1





                                              Or Alt-! twice. Or Ctrl-x ! once. So many possibilities!

                                              – Victor Zamanian
                                              Feb 2 '13 at 23:56








                                            3




                                            3





                                            Or try hitting Esc at the start of a blank line four times.

                                            – ephemient
                                            Jun 4 '09 at 1:55





                                            Or try hitting Esc at the start of a blank line four times.

                                            – ephemient
                                            Jun 4 '09 at 1:55













                                            That's amazingly useful, and I didn't already know it thanks :-)

                                            – Chris Huang-Leaver
                                            Jun 4 '09 at 7:27





                                            That's amazingly useful, and I didn't already know it thanks :-)

                                            – Chris Huang-Leaver
                                            Jun 4 '09 at 7:27




                                            4




                                            4





                                            Or Press Tab twice.

                                            – danio
                                            Jul 21 '10 at 8:48





                                            Or Press Tab twice.

                                            – danio
                                            Jul 21 '10 at 8:48




                                            1




                                            1





                                            Or Alt-! twice. Or Ctrl-x ! once. So many possibilities!

                                            – Victor Zamanian
                                            Feb 2 '13 at 23:56





                                            Or Alt-! twice. Or Ctrl-x ! once. So many possibilities!

                                            – Victor Zamanian
                                            Feb 2 '13 at 23:56











                                            2














                                            Here's a solution that gives you a list of all executables and aliases. It's also portable to systems without xargs -d (e.g. Mac OS X), and properly handles paths with spaces in them.



                                            #!/bin/bash
                                            (echo -n $PATH | tr : '' | xargs -0 -n 1 ls; alias | sed 's/alias ([^=]*)=.*/1/') | sort -u | grep "$@"


                                            Usage: myscript.sh [grep-options] pattern, e.g. to find all commands that begin with ls, case-insensitive, do:



                                            myscript -i ^ls





                                            share|improve this answer




























                                              2














                                              Here's a solution that gives you a list of all executables and aliases. It's also portable to systems without xargs -d (e.g. Mac OS X), and properly handles paths with spaces in them.



                                              #!/bin/bash
                                              (echo -n $PATH | tr : '' | xargs -0 -n 1 ls; alias | sed 's/alias ([^=]*)=.*/1/') | sort -u | grep "$@"


                                              Usage: myscript.sh [grep-options] pattern, e.g. to find all commands that begin with ls, case-insensitive, do:



                                              myscript -i ^ls





                                              share|improve this answer


























                                                2












                                                2








                                                2







                                                Here's a solution that gives you a list of all executables and aliases. It's also portable to systems without xargs -d (e.g. Mac OS X), and properly handles paths with spaces in them.



                                                #!/bin/bash
                                                (echo -n $PATH | tr : '' | xargs -0 -n 1 ls; alias | sed 's/alias ([^=]*)=.*/1/') | sort -u | grep "$@"


                                                Usage: myscript.sh [grep-options] pattern, e.g. to find all commands that begin with ls, case-insensitive, do:



                                                myscript -i ^ls





                                                share|improve this answer













                                                Here's a solution that gives you a list of all executables and aliases. It's also portable to systems without xargs -d (e.g. Mac OS X), and properly handles paths with spaces in them.



                                                #!/bin/bash
                                                (echo -n $PATH | tr : '' | xargs -0 -n 1 ls; alias | sed 's/alias ([^=]*)=.*/1/') | sort -u | grep "$@"


                                                Usage: myscript.sh [grep-options] pattern, e.g. to find all commands that begin with ls, case-insensitive, do:



                                                myscript -i ^ls






                                                share|improve this answer












                                                share|improve this answer



                                                share|improve this answer










                                                answered Jun 4 '09 at 1:50









                                                Adam RosenfieldAdam Rosenfield

                                                309k79449541




                                                309k79449541























                                                    2














                                                    shortcut method to list out all commands.
                                                    Open terminal and press two times "tab" button.
                                                    Thats show all commands in terminal






                                                    share|improve this answer



















                                                    • 1





                                                      And you pipe that into grep exactly how?

                                                      – Toby Speight
                                                      Jul 20 '17 at 9:05
















                                                    2














                                                    shortcut method to list out all commands.
                                                    Open terminal and press two times "tab" button.
                                                    Thats show all commands in terminal






                                                    share|improve this answer



















                                                    • 1





                                                      And you pipe that into grep exactly how?

                                                      – Toby Speight
                                                      Jul 20 '17 at 9:05














                                                    2












                                                    2








                                                    2







                                                    shortcut method to list out all commands.
                                                    Open terminal and press two times "tab" button.
                                                    Thats show all commands in terminal






                                                    share|improve this answer













                                                    shortcut method to list out all commands.
                                                    Open terminal and press two times "tab" button.
                                                    Thats show all commands in terminal







                                                    share|improve this answer












                                                    share|improve this answer



                                                    share|improve this answer










                                                    answered Sep 25 '16 at 19:24









                                                    dennydenny

                                                    1,3512916




                                                    1,3512916








                                                    • 1





                                                      And you pipe that into grep exactly how?

                                                      – Toby Speight
                                                      Jul 20 '17 at 9:05














                                                    • 1





                                                      And you pipe that into grep exactly how?

                                                      – Toby Speight
                                                      Jul 20 '17 at 9:05








                                                    1




                                                    1





                                                    And you pipe that into grep exactly how?

                                                    – Toby Speight
                                                    Jul 20 '17 at 9:05





                                                    And you pipe that into grep exactly how?

                                                    – Toby Speight
                                                    Jul 20 '17 at 9:05











                                                    1














                                                    You can always to the following:



                                                    1. Hold the $PATH environment variable value.
                                                    2. Split by ":"
                                                    3. For earch entry:
                                                    ls * $entry
                                                    4. grep your command in that output.


                                                    The shell will execute command only if they are listed in the path env var anyway.






                                                    share|improve this answer
























                                                    • Nice pseudo-code hehehe

                                                      – victor hugo
                                                      Jun 4 '09 at 0:41











                                                    • :P .

                                                      – OscarRyz
                                                      Jun 4 '09 at 0:45
















                                                    1














                                                    You can always to the following:



                                                    1. Hold the $PATH environment variable value.
                                                    2. Split by ":"
                                                    3. For earch entry:
                                                    ls * $entry
                                                    4. grep your command in that output.


                                                    The shell will execute command only if they are listed in the path env var anyway.






                                                    share|improve this answer
























                                                    • Nice pseudo-code hehehe

                                                      – victor hugo
                                                      Jun 4 '09 at 0:41











                                                    • :P .

                                                      – OscarRyz
                                                      Jun 4 '09 at 0:45














                                                    1












                                                    1








                                                    1







                                                    You can always to the following:



                                                    1. Hold the $PATH environment variable value.
                                                    2. Split by ":"
                                                    3. For earch entry:
                                                    ls * $entry
                                                    4. grep your command in that output.


                                                    The shell will execute command only if they are listed in the path env var anyway.






                                                    share|improve this answer













                                                    You can always to the following:



                                                    1. Hold the $PATH environment variable value.
                                                    2. Split by ":"
                                                    3. For earch entry:
                                                    ls * $entry
                                                    4. grep your command in that output.


                                                    The shell will execute command only if they are listed in the path env var anyway.







                                                    share|improve this answer












                                                    share|improve this answer



                                                    share|improve this answer










                                                    answered Jun 4 '09 at 0:39









                                                    OscarRyzOscarRyz

                                                    143k99338518




                                                    143k99338518













                                                    • Nice pseudo-code hehehe

                                                      – victor hugo
                                                      Jun 4 '09 at 0:41











                                                    • :P .

                                                      – OscarRyz
                                                      Jun 4 '09 at 0:45



















                                                    • Nice pseudo-code hehehe

                                                      – victor hugo
                                                      Jun 4 '09 at 0:41











                                                    • :P .

                                                      – OscarRyz
                                                      Jun 4 '09 at 0:45

















                                                    Nice pseudo-code hehehe

                                                    – victor hugo
                                                    Jun 4 '09 at 0:41





                                                    Nice pseudo-code hehehe

                                                    – victor hugo
                                                    Jun 4 '09 at 0:41













                                                    :P .

                                                    – OscarRyz
                                                    Jun 4 '09 at 0:45





                                                    :P .

                                                    – OscarRyz
                                                    Jun 4 '09 at 0:45











                                                    1














                                                    it depends, by that I mean it depends on what shell you are using. here are the constraints I see:




                                                    1. must run in the same process as your shell, to catch aliases and functions and variables that would effect the commands you can find, think PATH or EDITOR although EDITOR might be out of scope. You can have unexported variables that can effect things.

                                                    2. it is shell specific or your going off into the kernel, /proc/pid/enviorn and friends do not have enough information


                                                    I use ZSH so here is a zsh answer, it does the following 3 things:




                                                    1. dumps path

                                                    2. dumps alias names

                                                    3. dumps functions that are in the env

                                                    4. sorts them


                                                    here it is:



                                                    feed_me() {
                                                    (alias | cut -f1 -d= ; hash -f; hash -v | cut -f 1 -d= ; typeset +f) | sort
                                                    }


                                                    If you use zsh this should do it.






                                                    share|improve this answer


























                                                    • what is the typeset +f for? I can't lookup it in man page.

                                                      – pambda
                                                      May 14 '17 at 3:45











                                                    • ok I sort it out, it's for generate the function

                                                      – pambda
                                                      May 14 '17 at 3:47
















                                                    1














                                                    it depends, by that I mean it depends on what shell you are using. here are the constraints I see:




                                                    1. must run in the same process as your shell, to catch aliases and functions and variables that would effect the commands you can find, think PATH or EDITOR although EDITOR might be out of scope. You can have unexported variables that can effect things.

                                                    2. it is shell specific or your going off into the kernel, /proc/pid/enviorn and friends do not have enough information


                                                    I use ZSH so here is a zsh answer, it does the following 3 things:




                                                    1. dumps path

                                                    2. dumps alias names

                                                    3. dumps functions that are in the env

                                                    4. sorts them


                                                    here it is:



                                                    feed_me() {
                                                    (alias | cut -f1 -d= ; hash -f; hash -v | cut -f 1 -d= ; typeset +f) | sort
                                                    }


                                                    If you use zsh this should do it.






                                                    share|improve this answer


























                                                    • what is the typeset +f for? I can't lookup it in man page.

                                                      – pambda
                                                      May 14 '17 at 3:45











                                                    • ok I sort it out, it's for generate the function

                                                      – pambda
                                                      May 14 '17 at 3:47














                                                    1












                                                    1








                                                    1







                                                    it depends, by that I mean it depends on what shell you are using. here are the constraints I see:




                                                    1. must run in the same process as your shell, to catch aliases and functions and variables that would effect the commands you can find, think PATH or EDITOR although EDITOR might be out of scope. You can have unexported variables that can effect things.

                                                    2. it is shell specific or your going off into the kernel, /proc/pid/enviorn and friends do not have enough information


                                                    I use ZSH so here is a zsh answer, it does the following 3 things:




                                                    1. dumps path

                                                    2. dumps alias names

                                                    3. dumps functions that are in the env

                                                    4. sorts them


                                                    here it is:



                                                    feed_me() {
                                                    (alias | cut -f1 -d= ; hash -f; hash -v | cut -f 1 -d= ; typeset +f) | sort
                                                    }


                                                    If you use zsh this should do it.






                                                    share|improve this answer















                                                    it depends, by that I mean it depends on what shell you are using. here are the constraints I see:




                                                    1. must run in the same process as your shell, to catch aliases and functions and variables that would effect the commands you can find, think PATH or EDITOR although EDITOR might be out of scope. You can have unexported variables that can effect things.

                                                    2. it is shell specific or your going off into the kernel, /proc/pid/enviorn and friends do not have enough information


                                                    I use ZSH so here is a zsh answer, it does the following 3 things:




                                                    1. dumps path

                                                    2. dumps alias names

                                                    3. dumps functions that are in the env

                                                    4. sorts them


                                                    here it is:



                                                    feed_me() {
                                                    (alias | cut -f1 -d= ; hash -f; hash -v | cut -f 1 -d= ; typeset +f) | sort
                                                    }


                                                    If you use zsh this should do it.







                                                    share|improve this answer














                                                    share|improve this answer



                                                    share|improve this answer








                                                    edited Feb 20 '13 at 14:56


























                                                    community wiki





                                                    2 revs, 2 users 89%
                                                    ms4720















                                                    • what is the typeset +f for? I can't lookup it in man page.

                                                      – pambda
                                                      May 14 '17 at 3:45











                                                    • ok I sort it out, it's for generate the function

                                                      – pambda
                                                      May 14 '17 at 3:47



















                                                    • what is the typeset +f for? I can't lookup it in man page.

                                                      – pambda
                                                      May 14 '17 at 3:45











                                                    • ok I sort it out, it's for generate the function

                                                      – pambda
                                                      May 14 '17 at 3:47

















                                                    what is the typeset +f for? I can't lookup it in man page.

                                                    – pambda
                                                    May 14 '17 at 3:45





                                                    what is the typeset +f for? I can't lookup it in man page.

                                                    – pambda
                                                    May 14 '17 at 3:45













                                                    ok I sort it out, it's for generate the function

                                                    – pambda
                                                    May 14 '17 at 3:47





                                                    ok I sort it out, it's for generate the function

                                                    – pambda
                                                    May 14 '17 at 3:47











                                                    1














                                                    Alternatively, you can get a convenient list of commands coupled with quick descriptions (as long as the command has a man page, which most do):



                                                    apropos -s 1 ''

                                                    -s 1 returns only "section 1" manpages which are entries for executable programs.

                                                    '' is a search for anything. (If you use an asterisk, on my system, bash throws in a search for all the files and folders in your current working directory.)


                                                    Then you just grep it like you want.



                                                    apropos -s 1 '' | grep xdg


                                                    yields:



                                                    xdg-desktop-icon (1) - command line tool for (un)installing icons to the desktop
                                                    xdg-desktop-menu (1) - command line tool for (un)installing desktop menu items
                                                    xdg-email (1) - command line tool for sending mail using the user's preferred e-mail composer
                                                    xdg-icon-resource (1) - command line tool for (un)installing icon resources
                                                    xdg-mime (1) - command line tool for querying information about file type handling and adding descriptions for new file types
                                                    xdg-open (1) - opens a file or URL in the user's preferred application
                                                    xdg-screensaver (1) - command line tool for controlling the screensaver
                                                    xdg-settings (1) - get various settings from the desktop environment
                                                    xdg-user-dir (1) - Find an XDG user dir
                                                    xdg-user-dirs-update (1) - Update XDG user dir configuration


                                                    The results don't appear to be sorted, so if you're looking for a long list, you can throw a | sort | into the middle, and then pipe that to a pager like less/more/most. ala:



                                                    apropos -s 1 '' | sort | grep zip | less


                                                    Which returns a sorted list of all commands that have "zip" in their name or their short description, and pumps that the "less" pager. (You could also replace "less" with $PAGER and use the default pager.)






                                                    share|improve this answer






























                                                      1














                                                      Alternatively, you can get a convenient list of commands coupled with quick descriptions (as long as the command has a man page, which most do):



                                                      apropos -s 1 ''

                                                      -s 1 returns only "section 1" manpages which are entries for executable programs.

                                                      '' is a search for anything. (If you use an asterisk, on my system, bash throws in a search for all the files and folders in your current working directory.)


                                                      Then you just grep it like you want.



                                                      apropos -s 1 '' | grep xdg


                                                      yields:



                                                      xdg-desktop-icon (1) - command line tool for (un)installing icons to the desktop
                                                      xdg-desktop-menu (1) - command line tool for (un)installing desktop menu items
                                                      xdg-email (1) - command line tool for sending mail using the user's preferred e-mail composer
                                                      xdg-icon-resource (1) - command line tool for (un)installing icon resources
                                                      xdg-mime (1) - command line tool for querying information about file type handling and adding descriptions for new file types
                                                      xdg-open (1) - opens a file or URL in the user's preferred application
                                                      xdg-screensaver (1) - command line tool for controlling the screensaver
                                                      xdg-settings (1) - get various settings from the desktop environment
                                                      xdg-user-dir (1) - Find an XDG user dir
                                                      xdg-user-dirs-update (1) - Update XDG user dir configuration


                                                      The results don't appear to be sorted, so if you're looking for a long list, you can throw a | sort | into the middle, and then pipe that to a pager like less/more/most. ala:



                                                      apropos -s 1 '' | sort | grep zip | less


                                                      Which returns a sorted list of all commands that have "zip" in their name or their short description, and pumps that the "less" pager. (You could also replace "less" with $PAGER and use the default pager.)






                                                      share|improve this answer




























                                                        1












                                                        1








                                                        1







                                                        Alternatively, you can get a convenient list of commands coupled with quick descriptions (as long as the command has a man page, which most do):



                                                        apropos -s 1 ''

                                                        -s 1 returns only "section 1" manpages which are entries for executable programs.

                                                        '' is a search for anything. (If you use an asterisk, on my system, bash throws in a search for all the files and folders in your current working directory.)


                                                        Then you just grep it like you want.



                                                        apropos -s 1 '' | grep xdg


                                                        yields:



                                                        xdg-desktop-icon (1) - command line tool for (un)installing icons to the desktop
                                                        xdg-desktop-menu (1) - command line tool for (un)installing desktop menu items
                                                        xdg-email (1) - command line tool for sending mail using the user's preferred e-mail composer
                                                        xdg-icon-resource (1) - command line tool for (un)installing icon resources
                                                        xdg-mime (1) - command line tool for querying information about file type handling and adding descriptions for new file types
                                                        xdg-open (1) - opens a file or URL in the user's preferred application
                                                        xdg-screensaver (1) - command line tool for controlling the screensaver
                                                        xdg-settings (1) - get various settings from the desktop environment
                                                        xdg-user-dir (1) - Find an XDG user dir
                                                        xdg-user-dirs-update (1) - Update XDG user dir configuration


                                                        The results don't appear to be sorted, so if you're looking for a long list, you can throw a | sort | into the middle, and then pipe that to a pager like less/more/most. ala:



                                                        apropos -s 1 '' | sort | grep zip | less


                                                        Which returns a sorted list of all commands that have "zip" in their name or their short description, and pumps that the "less" pager. (You could also replace "less" with $PAGER and use the default pager.)






                                                        share|improve this answer















                                                        Alternatively, you can get a convenient list of commands coupled with quick descriptions (as long as the command has a man page, which most do):



                                                        apropos -s 1 ''

                                                        -s 1 returns only "section 1" manpages which are entries for executable programs.

                                                        '' is a search for anything. (If you use an asterisk, on my system, bash throws in a search for all the files and folders in your current working directory.)


                                                        Then you just grep it like you want.



                                                        apropos -s 1 '' | grep xdg


                                                        yields:



                                                        xdg-desktop-icon (1) - command line tool for (un)installing icons to the desktop
                                                        xdg-desktop-menu (1) - command line tool for (un)installing desktop menu items
                                                        xdg-email (1) - command line tool for sending mail using the user's preferred e-mail composer
                                                        xdg-icon-resource (1) - command line tool for (un)installing icon resources
                                                        xdg-mime (1) - command line tool for querying information about file type handling and adding descriptions for new file types
                                                        xdg-open (1) - opens a file or URL in the user's preferred application
                                                        xdg-screensaver (1) - command line tool for controlling the screensaver
                                                        xdg-settings (1) - get various settings from the desktop environment
                                                        xdg-user-dir (1) - Find an XDG user dir
                                                        xdg-user-dirs-update (1) - Update XDG user dir configuration


                                                        The results don't appear to be sorted, so if you're looking for a long list, you can throw a | sort | into the middle, and then pipe that to a pager like less/more/most. ala:



                                                        apropos -s 1 '' | sort | grep zip | less


                                                        Which returns a sorted list of all commands that have "zip" in their name or their short description, and pumps that the "less" pager. (You could also replace "less" with $PAGER and use the default pager.)







                                                        share|improve this answer














                                                        share|improve this answer



                                                        share|improve this answer








                                                        edited Sep 11 '17 at 8:08

























                                                        answered Sep 11 '17 at 7:59









                                                        Katastic VoyageKatastic Voyage

                                                        383211




                                                        383211























                                                            0














                                                            The problem is that the tab-completion is searching your path, but all commands are not in your path.



                                                            To find the commands in your path using bash you could do something like :



                                                            for x in echo $PATH | cut -d":" -f1; do ls $x; done






                                                            share|improve this answer




























                                                              0














                                                              The problem is that the tab-completion is searching your path, but all commands are not in your path.



                                                              To find the commands in your path using bash you could do something like :



                                                              for x in echo $PATH | cut -d":" -f1; do ls $x; done






                                                              share|improve this answer


























                                                                0












                                                                0








                                                                0







                                                                The problem is that the tab-completion is searching your path, but all commands are not in your path.



                                                                To find the commands in your path using bash you could do something like :



                                                                for x in echo $PATH | cut -d":" -f1; do ls $x; done






                                                                share|improve this answer













                                                                The problem is that the tab-completion is searching your path, but all commands are not in your path.



                                                                To find the commands in your path using bash you could do something like :



                                                                for x in echo $PATH | cut -d":" -f1; do ls $x; done







                                                                share|improve this answer












                                                                share|improve this answer



                                                                share|improve this answer










                                                                answered Jun 4 '09 at 0:42









                                                                nikudesunikudesu

                                                                21813




                                                                21813























                                                                    0














                                                                    Here's a function you can put in your bashrc file:




                                                                    function command-search
                                                                    {
                                                                    oldIFS=${IFS}
                                                                    IFS=":"

                                                                    for p in ${PATH}
                                                                    do
                                                                    ls $p | grep $1
                                                                    done

                                                                    export IFS=${oldIFS}
                                                                    }


                                                                    Example usage:




                                                                    $ command-search gnome
                                                                    gnome-audio-profiles-properties*
                                                                    gnome-eject@
                                                                    gnome-keyring*
                                                                    gnome-keyring-daemon*
                                                                    gnome-mount*
                                                                    gnome-open*
                                                                    gnome-sound-recorder*
                                                                    gnome-text-editor@
                                                                    gnome-umount@
                                                                    gnome-volume-control*
                                                                    polkit-gnome-authorization*
                                                                    vim.gnome*
                                                                    $


                                                                    FYI: IFS is a variable that bash uses to split strings.



                                                                    Certainly there could be some better ways to do this.






                                                                    share|improve this answer




























                                                                      0














                                                                      Here's a function you can put in your bashrc file:




                                                                      function command-search
                                                                      {
                                                                      oldIFS=${IFS}
                                                                      IFS=":"

                                                                      for p in ${PATH}
                                                                      do
                                                                      ls $p | grep $1
                                                                      done

                                                                      export IFS=${oldIFS}
                                                                      }


                                                                      Example usage:




                                                                      $ command-search gnome
                                                                      gnome-audio-profiles-properties*
                                                                      gnome-eject@
                                                                      gnome-keyring*
                                                                      gnome-keyring-daemon*
                                                                      gnome-mount*
                                                                      gnome-open*
                                                                      gnome-sound-recorder*
                                                                      gnome-text-editor@
                                                                      gnome-umount@
                                                                      gnome-volume-control*
                                                                      polkit-gnome-authorization*
                                                                      vim.gnome*
                                                                      $


                                                                      FYI: IFS is a variable that bash uses to split strings.



                                                                      Certainly there could be some better ways to do this.






                                                                      share|improve this answer


























                                                                        0












                                                                        0








                                                                        0







                                                                        Here's a function you can put in your bashrc file:




                                                                        function command-search
                                                                        {
                                                                        oldIFS=${IFS}
                                                                        IFS=":"

                                                                        for p in ${PATH}
                                                                        do
                                                                        ls $p | grep $1
                                                                        done

                                                                        export IFS=${oldIFS}
                                                                        }


                                                                        Example usage:




                                                                        $ command-search gnome
                                                                        gnome-audio-profiles-properties*
                                                                        gnome-eject@
                                                                        gnome-keyring*
                                                                        gnome-keyring-daemon*
                                                                        gnome-mount*
                                                                        gnome-open*
                                                                        gnome-sound-recorder*
                                                                        gnome-text-editor@
                                                                        gnome-umount@
                                                                        gnome-volume-control*
                                                                        polkit-gnome-authorization*
                                                                        vim.gnome*
                                                                        $


                                                                        FYI: IFS is a variable that bash uses to split strings.



                                                                        Certainly there could be some better ways to do this.






                                                                        share|improve this answer













                                                                        Here's a function you can put in your bashrc file:




                                                                        function command-search
                                                                        {
                                                                        oldIFS=${IFS}
                                                                        IFS=":"

                                                                        for p in ${PATH}
                                                                        do
                                                                        ls $p | grep $1
                                                                        done

                                                                        export IFS=${oldIFS}
                                                                        }


                                                                        Example usage:




                                                                        $ command-search gnome
                                                                        gnome-audio-profiles-properties*
                                                                        gnome-eject@
                                                                        gnome-keyring*
                                                                        gnome-keyring-daemon*
                                                                        gnome-mount*
                                                                        gnome-open*
                                                                        gnome-sound-recorder*
                                                                        gnome-text-editor@
                                                                        gnome-umount@
                                                                        gnome-volume-control*
                                                                        polkit-gnome-authorization*
                                                                        vim.gnome*
                                                                        $


                                                                        FYI: IFS is a variable that bash uses to split strings.



                                                                        Certainly there could be some better ways to do this.







                                                                        share|improve this answer












                                                                        share|improve this answer



                                                                        share|improve this answer










                                                                        answered Jun 4 '09 at 0:58









                                                                        Craig WrightCraig Wright

                                                                        1,1091819




                                                                        1,1091819























                                                                            -1














                                                                            maybe i'm misunderstanding but what if you press Escape until you got the Display All X possibilities ?






                                                                            share|improve this answer




























                                                                              -1














                                                                              maybe i'm misunderstanding but what if you press Escape until you got the Display All X possibilities ?






                                                                              share|improve this answer


























                                                                                -1












                                                                                -1








                                                                                -1







                                                                                maybe i'm misunderstanding but what if you press Escape until you got the Display All X possibilities ?






                                                                                share|improve this answer













                                                                                maybe i'm misunderstanding but what if you press Escape until you got the Display All X possibilities ?







                                                                                share|improve this answer












                                                                                share|improve this answer



                                                                                share|improve this answer










                                                                                answered Jun 4 '09 at 1:02









                                                                                LB40LB40

                                                                                6,5971458100




                                                                                6,5971458100























                                                                                    -1














                                                                                    Basic commands:



                                                                                    $ touch :- user for create empty file



                                                                                    Syn:- touch filename



                                                                                    Ex: touch rama



                                                                                    $ls list of files and directories



                                                                                    $ ls –l Long listing



                                                                                    File type, permissions, link files, user(or)owner name, group name, file size, time stamp, file or dir name.



                                                                                    – regular (or) normal file



                                                                                    d directory



                                                                                    l link file



                                                                                    ls –a : show the all (including hidden files)



                                                                                    Hidden files and directories start with . (dot)



                                                                                    find more commands @ http://k2schools.com/linux-commands/






                                                                                    share|improve this answer




























                                                                                      -1














                                                                                      Basic commands:



                                                                                      $ touch :- user for create empty file



                                                                                      Syn:- touch filename



                                                                                      Ex: touch rama



                                                                                      $ls list of files and directories



                                                                                      $ ls –l Long listing



                                                                                      File type, permissions, link files, user(or)owner name, group name, file size, time stamp, file or dir name.



                                                                                      – regular (or) normal file



                                                                                      d directory



                                                                                      l link file



                                                                                      ls –a : show the all (including hidden files)



                                                                                      Hidden files and directories start with . (dot)



                                                                                      find more commands @ http://k2schools.com/linux-commands/






                                                                                      share|improve this answer


























                                                                                        -1












                                                                                        -1








                                                                                        -1







                                                                                        Basic commands:



                                                                                        $ touch :- user for create empty file



                                                                                        Syn:- touch filename



                                                                                        Ex: touch rama



                                                                                        $ls list of files and directories



                                                                                        $ ls –l Long listing



                                                                                        File type, permissions, link files, user(or)owner name, group name, file size, time stamp, file or dir name.



                                                                                        – regular (or) normal file



                                                                                        d directory



                                                                                        l link file



                                                                                        ls –a : show the all (including hidden files)



                                                                                        Hidden files and directories start with . (dot)



                                                                                        find more commands @ http://k2schools.com/linux-commands/






                                                                                        share|improve this answer













                                                                                        Basic commands:



                                                                                        $ touch :- user for create empty file



                                                                                        Syn:- touch filename



                                                                                        Ex: touch rama



                                                                                        $ls list of files and directories



                                                                                        $ ls –l Long listing



                                                                                        File type, permissions, link files, user(or)owner name, group name, file size, time stamp, file or dir name.



                                                                                        – regular (or) normal file



                                                                                        d directory



                                                                                        l link file



                                                                                        ls –a : show the all (including hidden files)



                                                                                        Hidden files and directories start with . (dot)



                                                                                        find more commands @ http://k2schools.com/linux-commands/







                                                                                        share|improve this answer












                                                                                        share|improve this answer



                                                                                        share|improve this answer










                                                                                        answered Aug 11 '15 at 6:50









                                                                                        reddyreddy

                                                                                        1




                                                                                        1























                                                                                            -2














                                                                                            compgen -c > list.txt && wc list.txt





                                                                                            share|improve this answer





















                                                                                            • 1





                                                                                              Consider adding a brief description of what this does or how this is supposed to work. At the very least, specify a reference link (usually the relevant man page) for following-up and understanding the proposed solution.

                                                                                              – TheCodeArtist
                                                                                              Apr 5 '15 at 3:57











                                                                                            • Using a file is not always a good option. If you do need to, then at least make it a tmp file (if security not an issue.) compgen -c > /tmp/list.txt && /tmp/wc list.txt

                                                                                              – Gary
                                                                                              Nov 5 '15 at 19:07
















                                                                                            -2














                                                                                            compgen -c > list.txt && wc list.txt





                                                                                            share|improve this answer





















                                                                                            • 1





                                                                                              Consider adding a brief description of what this does or how this is supposed to work. At the very least, specify a reference link (usually the relevant man page) for following-up and understanding the proposed solution.

                                                                                              – TheCodeArtist
                                                                                              Apr 5 '15 at 3:57











                                                                                            • Using a file is not always a good option. If you do need to, then at least make it a tmp file (if security not an issue.) compgen -c > /tmp/list.txt && /tmp/wc list.txt

                                                                                              – Gary
                                                                                              Nov 5 '15 at 19:07














                                                                                            -2












                                                                                            -2








                                                                                            -2







                                                                                            compgen -c > list.txt && wc list.txt





                                                                                            share|improve this answer















                                                                                            compgen -c > list.txt && wc list.txt






                                                                                            share|improve this answer














                                                                                            share|improve this answer



                                                                                            share|improve this answer








                                                                                            edited Apr 5 '15 at 4:55









                                                                                            reuben

                                                                                            3,1891928




                                                                                            3,1891928










                                                                                            answered Apr 5 '15 at 0:05









                                                                                            some1some1

                                                                                            1




                                                                                            1








                                                                                            • 1





                                                                                              Consider adding a brief description of what this does or how this is supposed to work. At the very least, specify a reference link (usually the relevant man page) for following-up and understanding the proposed solution.

                                                                                              – TheCodeArtist
                                                                                              Apr 5 '15 at 3:57











                                                                                            • Using a file is not always a good option. If you do need to, then at least make it a tmp file (if security not an issue.) compgen -c > /tmp/list.txt && /tmp/wc list.txt

                                                                                              – Gary
                                                                                              Nov 5 '15 at 19:07














                                                                                            • 1





                                                                                              Consider adding a brief description of what this does or how this is supposed to work. At the very least, specify a reference link (usually the relevant man page) for following-up and understanding the proposed solution.

                                                                                              – TheCodeArtist
                                                                                              Apr 5 '15 at 3:57











                                                                                            • Using a file is not always a good option. If you do need to, then at least make it a tmp file (if security not an issue.) compgen -c > /tmp/list.txt && /tmp/wc list.txt

                                                                                              – Gary
                                                                                              Nov 5 '15 at 19:07








                                                                                            1




                                                                                            1





                                                                                            Consider adding a brief description of what this does or how this is supposed to work. At the very least, specify a reference link (usually the relevant man page) for following-up and understanding the proposed solution.

                                                                                            – TheCodeArtist
                                                                                            Apr 5 '15 at 3:57





                                                                                            Consider adding a brief description of what this does or how this is supposed to work. At the very least, specify a reference link (usually the relevant man page) for following-up and understanding the proposed solution.

                                                                                            – TheCodeArtist
                                                                                            Apr 5 '15 at 3:57













                                                                                            Using a file is not always a good option. If you do need to, then at least make it a tmp file (if security not an issue.) compgen -c > /tmp/list.txt && /tmp/wc list.txt

                                                                                            – Gary
                                                                                            Nov 5 '15 at 19:07





                                                                                            Using a file is not always a good option. If you do need to, then at least make it a tmp file (if security not an issue.) compgen -c > /tmp/list.txt && /tmp/wc list.txt

                                                                                            – Gary
                                                                                            Nov 5 '15 at 19:07











                                                                                            -3














                                                                                            Why don't you just type:



                                                                                            seachstr


                                                                                            In the terminal.



                                                                                            The shell will say somehing like



                                                                                            seacrhstr: command not found 


                                                                                            EDIT:



                                                                                            Ok, I take the downvote, because the answer is stupid, I just want to know: What's wrong with this answer!!! The asker said:




                                                                                            and see if a command is available.




                                                                                            Typing the command will tell you if it is available!.



                                                                                            Probably he/she meant "with out executing the command" or "to include it in a script" but I cannot read his mind ( is not that I can't regularly it is just that he's wearing a
                                                                                            mind reading deflector )






                                                                                            share|improve this answer





















                                                                                            • 4





                                                                                              I want to know whether formathdd command exists. Oh wait, I just to run it and see. gee. Thanks :)

                                                                                              – Jeffrey Jose
                                                                                              Apr 24 '10 at 10:52






                                                                                            • 4





                                                                                              Probably safer to use 'which' to do that.

                                                                                              – danio
                                                                                              Jul 20 '10 at 15:01













                                                                                            • Given that this is Stack Overflow, not Super User, a programmatic answer would be more appropriate.

                                                                                              – Toby Speight
                                                                                              Jul 20 '17 at 9:04
















                                                                                            -3














                                                                                            Why don't you just type:



                                                                                            seachstr


                                                                                            In the terminal.



                                                                                            The shell will say somehing like



                                                                                            seacrhstr: command not found 


                                                                                            EDIT:



                                                                                            Ok, I take the downvote, because the answer is stupid, I just want to know: What's wrong with this answer!!! The asker said:




                                                                                            and see if a command is available.




                                                                                            Typing the command will tell you if it is available!.



                                                                                            Probably he/she meant "with out executing the command" or "to include it in a script" but I cannot read his mind ( is not that I can't regularly it is just that he's wearing a
                                                                                            mind reading deflector )






                                                                                            share|improve this answer





















                                                                                            • 4





                                                                                              I want to know whether formathdd command exists. Oh wait, I just to run it and see. gee. Thanks :)

                                                                                              – Jeffrey Jose
                                                                                              Apr 24 '10 at 10:52






                                                                                            • 4





                                                                                              Probably safer to use 'which' to do that.

                                                                                              – danio
                                                                                              Jul 20 '10 at 15:01













                                                                                            • Given that this is Stack Overflow, not Super User, a programmatic answer would be more appropriate.

                                                                                              – Toby Speight
                                                                                              Jul 20 '17 at 9:04














                                                                                            -3












                                                                                            -3








                                                                                            -3







                                                                                            Why don't you just type:



                                                                                            seachstr


                                                                                            In the terminal.



                                                                                            The shell will say somehing like



                                                                                            seacrhstr: command not found 


                                                                                            EDIT:



                                                                                            Ok, I take the downvote, because the answer is stupid, I just want to know: What's wrong with this answer!!! The asker said:




                                                                                            and see if a command is available.




                                                                                            Typing the command will tell you if it is available!.



                                                                                            Probably he/she meant "with out executing the command" or "to include it in a script" but I cannot read his mind ( is not that I can't regularly it is just that he's wearing a
                                                                                            mind reading deflector )






                                                                                            share|improve this answer















                                                                                            Why don't you just type:



                                                                                            seachstr


                                                                                            In the terminal.



                                                                                            The shell will say somehing like



                                                                                            seacrhstr: command not found 


                                                                                            EDIT:



                                                                                            Ok, I take the downvote, because the answer is stupid, I just want to know: What's wrong with this answer!!! The asker said:




                                                                                            and see if a command is available.




                                                                                            Typing the command will tell you if it is available!.



                                                                                            Probably he/she meant "with out executing the command" or "to include it in a script" but I cannot read his mind ( is not that I can't regularly it is just that he's wearing a
                                                                                            mind reading deflector )







                                                                                            share|improve this answer














                                                                                            share|improve this answer



                                                                                            share|improve this answer








                                                                                            edited Jun 4 '09 at 0:57

























                                                                                            answered Jun 4 '09 at 0:35









                                                                                            OscarRyzOscarRyz

                                                                                            143k99338518




                                                                                            143k99338518








                                                                                            • 4





                                                                                              I want to know whether formathdd command exists. Oh wait, I just to run it and see. gee. Thanks :)

                                                                                              – Jeffrey Jose
                                                                                              Apr 24 '10 at 10:52






                                                                                            • 4





                                                                                              Probably safer to use 'which' to do that.

                                                                                              – danio
                                                                                              Jul 20 '10 at 15:01













                                                                                            • Given that this is Stack Overflow, not Super User, a programmatic answer would be more appropriate.

                                                                                              – Toby Speight
                                                                                              Jul 20 '17 at 9:04














                                                                                            • 4





                                                                                              I want to know whether formathdd command exists. Oh wait, I just to run it and see. gee. Thanks :)

                                                                                              – Jeffrey Jose
                                                                                              Apr 24 '10 at 10:52






                                                                                            • 4





                                                                                              Probably safer to use 'which' to do that.

                                                                                              – danio
                                                                                              Jul 20 '10 at 15:01













                                                                                            • Given that this is Stack Overflow, not Super User, a programmatic answer would be more appropriate.

                                                                                              – Toby Speight
                                                                                              Jul 20 '17 at 9:04








                                                                                            4




                                                                                            4





                                                                                            I want to know whether formathdd command exists. Oh wait, I just to run it and see. gee. Thanks :)

                                                                                            – Jeffrey Jose
                                                                                            Apr 24 '10 at 10:52





                                                                                            I want to know whether formathdd command exists. Oh wait, I just to run it and see. gee. Thanks :)

                                                                                            – Jeffrey Jose
                                                                                            Apr 24 '10 at 10:52




                                                                                            4




                                                                                            4





                                                                                            Probably safer to use 'which' to do that.

                                                                                            – danio
                                                                                            Jul 20 '10 at 15:01







                                                                                            Probably safer to use 'which' to do that.

                                                                                            – danio
                                                                                            Jul 20 '10 at 15:01















                                                                                            Given that this is Stack Overflow, not Super User, a programmatic answer would be more appropriate.

                                                                                            – Toby Speight
                                                                                            Jul 20 '17 at 9:04





                                                                                            Given that this is Stack Overflow, not Super User, a programmatic answer would be more appropriate.

                                                                                            – Toby Speight
                                                                                            Jul 20 '17 at 9:04











                                                                                            -5














                                                                                            in debian: ls /bin/ | grep "whatImSearchingFor"






                                                                                            share|improve this answer



















                                                                                            • 1





                                                                                              executables exist in all the directories in $PATH, not just /bin.

                                                                                              – PhrkOnLsh
                                                                                              Jun 4 '09 at 14:52
















                                                                                            -5














                                                                                            in debian: ls /bin/ | grep "whatImSearchingFor"






                                                                                            share|improve this answer



















                                                                                            • 1





                                                                                              executables exist in all the directories in $PATH, not just /bin.

                                                                                              – PhrkOnLsh
                                                                                              Jun 4 '09 at 14:52














                                                                                            -5












                                                                                            -5








                                                                                            -5







                                                                                            in debian: ls /bin/ | grep "whatImSearchingFor"






                                                                                            share|improve this answer













                                                                                            in debian: ls /bin/ | grep "whatImSearchingFor"







                                                                                            share|improve this answer












                                                                                            share|improve this answer



                                                                                            share|improve this answer










                                                                                            answered Jun 4 '09 at 0:37









                                                                                            Gabriel SosaGabriel Sosa

                                                                                            6,47933248




                                                                                            6,47933248








                                                                                            • 1





                                                                                              executables exist in all the directories in $PATH, not just /bin.

                                                                                              – PhrkOnLsh
                                                                                              Jun 4 '09 at 14:52














                                                                                            • 1





                                                                                              executables exist in all the directories in $PATH, not just /bin.

                                                                                              – PhrkOnLsh
                                                                                              Jun 4 '09 at 14:52








                                                                                            1




                                                                                            1





                                                                                            executables exist in all the directories in $PATH, not just /bin.

                                                                                            – PhrkOnLsh
                                                                                            Jun 4 '09 at 14:52





                                                                                            executables exist in all the directories in $PATH, not just /bin.

                                                                                            – PhrkOnLsh
                                                                                            Jun 4 '09 at 14:52


















                                                                                            draft saved

                                                                                            draft discarded




















































                                                                                            Thanks for contributing an answer to Stack Overflow!


                                                                                            • Please be sure to answer the question. Provide details and share your research!

                                                                                            But avoid



                                                                                            • Asking for help, clarification, or responding to other answers.

                                                                                            • Making statements based on opinion; back them up with references or personal experience.


                                                                                            To learn more, see our tips on writing great answers.




                                                                                            draft saved


                                                                                            draft discarded














                                                                                            StackExchange.ready(
                                                                                            function () {
                                                                                            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f948008%2flinux-command-to-list-all-available-commands-and-aliases%23new-answer', 'question_page');
                                                                                            }
                                                                                            );

                                                                                            Post as a guest















                                                                                            Required, but never shown





















































                                                                                            Required, but never shown














                                                                                            Required, but never shown












                                                                                            Required, but never shown







                                                                                            Required, but never shown

































                                                                                            Required, but never shown














                                                                                            Required, but never shown












                                                                                            Required, but never shown







                                                                                            Required, but never shown







                                                                                            Popular posts from this blog

                                                                                            Xamarin.iOS Cant Deploy on Iphone

                                                                                            Glorious Revolution

                                                                                            Dulmage-Mendelsohn matrix decomposition in Python