A shell builtin is a command called from a shell, that is executed directly in the shell itself.
Questions tagged [shell-builtin]
156 questions
140
votes
7 answers
Why is cd not a program?
I've always wondered why cd isn't a program, but never managed to find the answer.
Anyone know why this is the case?
AkshaiShah
- 3,599
- 5
- 18
- 9
111
votes
5 answers
What's the difference between eval and exec?
eval and exec are both built in commands of bash(1) that execute commands.
I also see exec has a few options but is that the only difference? What happens to their context?
Willian Paixao
- 2,691
- 3
- 18
- 33
89
votes
4 answers
What is the difference between a builtin command and one that is not?
Is there any intrinsic difference between a builtin command and another command which can nominally do the same thing?
eg. Do builtins get "special" treatement? ... is there less overhead running them? .. or are they just simply 'built in'; like…
Peter.O
- 32,426
- 28
- 115
- 163
84
votes
2 answers
Can I get individual man pages for the bash builtin commands?
Is there anywhere you can download a manpage for every builtin commands?
I know you can just use help or man bash and search to find info about it, but I want them separated, so I can just do man read and get the read manpage.
Tyilo
- 5,891
- 12
- 47
- 61
72
votes
4 answers
Why is `[` a shell builtin and `[[` a shell keyword?
As far as I know, [[ is an enhanced version of [, but I am confused when I see [[ as a keyword and [ being shown as a builtin.
[root@server ~]# type [
[ is a shell builtin
[root@server ~]# type [[
[[ is a shell keyword
TLDP says
A builtin may be…
Sreeraj
- 4,984
- 10
- 38
- 57
63
votes
2 answers
Understand `compgen` builtin command
From help compgen:
$ help compgen
compgen: compgen [-abcdefgjksuv] [-o option] [-A action] [-G globpat] [-W wordlist] [-F function] [-C command] [-X filterpat] [-P prefix] [-S suffix] [word]
Display possible completions depending on the…
Pandya
- 23,898
- 29
- 92
- 144
52
votes
7 answers
What purpose does the colon builtin ':' serve?
I've hacked on a lot of shell scripts, and sometimes the simplest things baffle me. Today I ran across a script that made extensive use of the : (colon) bash builtin.
The documenation seems simple enough:
: (a colon)
: [arguments]
Do…
Caleb
- 69,278
- 18
- 196
- 226
49
votes
5 answers
What is "declare" in Bash?
After reading ilkkachu's answer to this question I learned on the existence of the declare (with argument -n) shell built in.
help declare brings:
Set variable values and attributes.
Declare variables and give them attributes. If no NAMEs are…
user149572
49
votes
8 answers
Why are POSIX mandatory utilities not built into the shell?
The purpose of this question is to answer a curiosity, not to solve a particular computing problem. The question is: Why are POSIX mandatory utilities not commonly built into shell implementations?
For example, I have a script that basically reads a…
Kyle
- 655
- 6
- 9
43
votes
6 answers
Why is echo a shell built in command?
$ which echo
echo: shell built-in command.
$ which ls
/bin/ls
$ which cat
/bin/cat
Why is echo not an independent utility like ls, ps, cat etc? Why is it shell specific? Any good reasons?
Lazer
- 34,477
- 25
- 70
- 75
33
votes
5 answers
Make bash use external `time` command rather than shell built-in
How can I make bash use time binary (/usr/bin/time) by default instead of the shell keyword?
which time returns /usr/bin/time
type time returns time is a shell keyword
Running time is obviously executing the shell keyword:
$ time
real …
David Holdeman
- 433
- 4
- 7
33
votes
6 answers
Is 'cat' a shell built-in or an external program?
When I use the type command to find out if cat is a shell built-in or an external program I get the output below:
-$ type cat
cat is hashed (/bin/cat)
-$
Does this mean that cat is an external program which is /bin/cat?
I got confused, because when…
sps
- 1,396
- 5
- 15
- 23
32
votes
1 answer
How to get the cd shell-builtin to stop guessing?
For example:
$ ls -aF
./ ../ bin/
$ cd tin # with a tee, not bee
bin
$ pwd
/home/user/bin
In other words, cd guesses that what I really meant was cd bin, and successfully (huh?) changes the current directory accordingly. I do not find this behavior…
Ana Nimbus
- 681
- 4
- 10
31
votes
5 answers
Can I make cd be local to a function?
Is it possible to make a function like
function doStuffAt {
cd $1
# do stuff
}
but make it so invoking that function doesn't actually change my pwd, it just changes it for duration of the function? I know I can save the pwd and set it back…
Mason
- 469
- 4
- 9
26
votes
2 answers
What is the purpose of the bash `suspend` builtin command?
I typed help suspend and got this short explanation:
suspend: suspend [-f]
Suspend shell execution.
Suspend the execution of this shell until it receives a SIGCONT signal.
Unless forced, login shells cannot be suspended.
Options:
…
sharkant
- 3,560
- 10
- 30
- 46