A shell builtin is a command called from a shell, that is executed directly in the shell itself.

learn more… | top users | synonyms

2
votes
1answer
16 views

Pipelines, Jobs and Processes in Zsh

I went through the Jobs & Signals documentation in Zsh, but some things aren't still clear to me. It says: If the MONITOR option is set, an interactive shell associates a job with each ...
0
votes
1answer
86 views

reading file using for, while - behavior

Consider the below scenario 2 vms - 192.168.229.131, 192.168.229.132 Both the vms has it's ip as 192.168.229.151 & 192.168.229.152 in it's /etc/hosts file Say there are around 50 vms like i ...
0
votes
1answer
47 views

What is the difference between the built in echo command and /bin/echo? [duplicate]

I was playing around with the type and which commands and I discovered something strange. type either returns the path or says that a command is a Bash built in. which either returns the path or ...
2
votes
1answer
62 views

strace works for some builtin commands

I'm trying to understand some kernel level concepts in Linux. I was checking on the difference between shell builtin commands and the other executable commands. This wonderful answer clearly tells ...
2
votes
2answers
256 views

Why does Bash's “source” command behave differently when called from a function?

Given the following sourceable bar Bash script ... echo :$#:"$@": ... and the following executable foo Bash script: echo -n source bar: source bar echo -n source bar foo: source bar foo function ...
1
vote
1answer
403 views

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] ...
7
votes
2answers
316 views

Change the order of executables started in bash

If I execute the test command in bash, test(evaluates conditional expression) built-in utility is started: $ type test test is a shell builtin $ type -a test test is a shell builtin test is ...
5
votes
2answers
139 views

Default preference of executable over built-ins with the same name

I was playing around a bit with the names of some executables, putting them in a folder, ~/bin, which is in my $PATH. Now I'm wondering how I can set the preferences of a bash-3.2 terminal so that it ...
1
vote
2answers
267 views

How to execute a builtin shell command using find?

I'm constrained to doing this in tcsh on CentOS due to the environment at work. When executing find . -type f -executable -exec source '{}' \; the only result is find: 'source': No such file or ...
1
vote
2answers
208 views

How to invoke a shell built-in explicitly?

I want to customize the functionality of cd command as per my needs. I define following function - function cd () { cd "$@" && pushd "$@"; } The intent of this function is to automatically ...
1
vote
1answer
679 views

A command that gives username@hostname:pwd

I know that pwd gives the current working directory, hostname gives the current host and whoami gives the current user. Is there a single unix command that will give me the output of ...
4
votes
3answers
405 views

Why is bash's printf faster than /usr/bin/printf?

I have two ways of calling printf on my system: $ type -a printf printf is a shell builtin printf is /usr/bin/printf $ file /usr/bin/printf /usr/bin/printf: ELF 64-bit LSB executable, x86-64, ...
7
votes
2answers
502 views

Possible to use brace (permutation) and array expansion simultaneously?

Bash's {} brace expansion syntax allows for creating easy permutations # echo {b,c,d}{a,e,i,o,u} ba be bi bo bu ca ce ci co cu da de di do du However it's not clear to me if/how it's possible to ...
9
votes
4answers
277 views

When are the built-in commands loaded to memory

Let's say if I type in cd in my shell. Is cd loaded from the memory at that moment? My intuition is that these built-in commands are pre-loaded to the system memory after the kernel has been loaded, ...
12
votes
4answers
2k views

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 ...
1
vote
2answers
81 views

Set shell environment variable without using a shell builtin command

I am using a program that takes a "command" as an argument and then adds some helpful wraping around it. Presumably in an effort to be helpful it appears to checks to make sure the command "exists". ...
2
votes
1answer
359 views

Bash pipe output to more

I am wondering about some bash environment setting here: is it possible to set stdout of bash as a pipe to /bin/more? You know, like using vi as editor for your commands it should be possible to avoid ...
1
vote
3answers
780 views

how does built in commands of a shell implemented in Linux? as a function or thread of shell process?

I know that external commands are run in the shell by creating a separate process. But what exactly happens when a built in command is run in a shell. Are they executed as a function or if the shell ...
1
vote
3answers
171 views

In bash, how can I erase an alias without logout? [duplicate]

I had an alias in my .bashrc and I really don't want it anymore. I erased the alias, but my bash already has this alias loaded. Can I erase this alias from this bash without logging out?
2
votes
1answer
122 views

An -e option to cd builtin

According to Bash reference on Bash builtins: cd [-L|[-P [-e]]] [directory] The -P option means to not follow symbolic links; symbolic links are followed by default or with the -L option. ...
8
votes
1answer
561 views

What is the difference between which and where

What is the difference between where and which shell commands? Here are some examples ~ where cc /usr/bin/cc /usr/bin/cc ~ which cc /usr/bin/cc and ~ which which which='alias | ...
1
vote
2answers
119 views

Are there any pitfalls to overriding ls?

Is there anything to watch out for if you wanted to override ls? Is there a more reliable way of getting pagination out of ls? For example: function ls() { command ls -hp $@ | more; }
3
votes
1answer
136 views

the return built-in

According to the Open Group, [t]he return utility shall cause the shell to stop executing the current function or dot script. If the shell is not currently executing a function or dot script, ...
2
votes
6answers
348 views

bash equivalent of this use of tcsh “sched” command?

In tcsh, the built-in sched command causes a command to be executed by the current shell at a specified time. I have the following $HOME/.sched file (this is a simplified version of it): setenv ...
4
votes
1answer
276 views

Why are parameters to Bash's builtin optional?

Running simply builtin prints nothing and returns exit code 0. This is in accordance with help builtin, which shows all parameters as optional. But why isn't this no-op an error? Is there a use case ...
22
votes
7answers
3k views

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 ...
9
votes
2answers
256 views

What is not shell specific?

Under some answers, I see comments that recommend avoiding shell specific commands in answers. How do I know which commands, operators, etc exist in all shells? Is there a list of standards? man ...
16
votes
2answers
2k views

Can I get individual man pages for the bash builtin commands? [duplicate]

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 ...
3
votes
2answers
2k views

Why does my shell script give the error: “declare: not found”?

Here is a simple example showing that using declare in a script the script will not run, while sourcing the script will: $ cat /tmp/new #! /bin/sh declare -i hello $ chmod a+rwx /tmp/new $ /tmp/new ...
32
votes
4answers
3k views

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 ...
2
votes
5answers
819 views

missing man pages of some commands

Typing man alias gives me No manual entry for alias The same thing goes for export and eval. At first I thought it only happens to shell built-in commands but man echo gives me the man page. ...
3
votes
2answers
927 views

Capture multi-line output of a bash builtin

Normally, bash is able to assign multi-line output of a command: L=`ls` This works from both interactive shell and scripts. But it appears the output of a builtin can't be captured in a variable: ...
19
votes
5answers
4k views

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?