solo2500
Posts: 123
Joined: Sat Jul 09, 2016 12:38 am

where are builtin commands located?

Wed Nov 23, 2016 4:59 pm

Where are builtin comands located... like say mapfile? When I run

Code: Select all

which mapfile
nothing is returned... but I know it's there.
I'm a total novice, non-programer (...basically a hack.)

User avatar
DougieLawson
Posts: 39124
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: where are builtin commands located?

Wed Nov 23, 2016 5:25 pm

That's one of the BASH built-in commands.
https://www.gnu.org/software/bash/manua ... ltins.html

They're part of /bin/bash and you can read the source code here: https://ftp.gnu.org/gnu/bash/
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

User avatar
rpdom
Posts: 17174
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: where are builtin commands located?

Wed Nov 23, 2016 9:12 pm

You can also get the equivalent of a "man" page on a builtin by typing "help whatever"

Code: Select all

pi@raspberrypi:~ $ help mapfile
mapfile: mapfile [-n count] [-O origin] [-s count] [-t] [-u fd] [-C callback] [-c quantum] [array]
    Read lines from the standard input into an indexed array variable.
    
    Read lines from the standard input into the indexed array variable ARRAY, or
    from file descriptor FD if the -u option is supplied.  The variable MAPFILE
    is the default ARRAY.
    
    Options:
      -n count	Copy at most COUNT lines.  If COUNT is 0, all lines are copied.
      -O origin	Begin assigning to ARRAY at index ORIGIN.  The default index is 0.
      -s count 	Discard the first COUNT lines read.
      -t		Remove a trailing newline from each line read.
      -u fd		Read lines from file descriptor FD instead of the standard input.
      -C callback	Evaluate CALLBACK each time QUANTUM lines are read.
      -c quantum	Specify the number of lines read between each call to CALLBACK.
    
    Arguments:
      ARRAY		Array variable name to use for file data.
    
    If -C is supplied without -c, the default quantum is 5000.  When
    CALLBACK is evaluated, it is supplied the index of the next array
    element to be assigned and the line to be assigned to that element
    as additional arguments.
    
    If not supplied with an explicit origin, mapfile will clear ARRAY before
    assigning to it.
    
    Exit Status:
    Returns success unless an invalid option is given or ARRAY is readonly or
    not an indexed array.

Return to “Beginners”