A shell builtin is a command called from a shell, that is executed directly in the shell itself.
1
vote
3answers
75 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
67 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. ...
7
votes
1answer
194 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
82 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
124 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, ...
1
vote
5answers
179 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
189 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 ...
13
votes
5answers
719 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 ...
6
votes
2answers
189 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 ...
10
votes
2answers
636 views
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 ...
2
votes
2answers
880 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
...
26
votes
4answers
2k 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
427 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
653 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:
...
16
votes
5answers
2k 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?