Bash shell builtin vs real command

Every now and then I’m hitting the problem of running a shell built-in when I want to run a real command. Built-in masks the command, of course.

Problem* is, one of them has options I want to use, the other does not (or has different ones).

Also, typing `man someBuiltInHere` gives you nothing, so you can’t check those options. So, few tricks about that.

* For those not so familiar with GNU/Linux it’s an even worse problem. For them the command doesn’t work with options it should’ve worked with.

Case 1: time

I want to use `time` command to see how many page faults I had when running something.

The option `-v` that shows page faults does NOT work with built in.

$ time -v elinks
-v: command not found

Case 2: kill

I want to list all signals kill takes in number – name (columnary) format.

$ kill -L
bash: kill: L: invalid signal specification

Tricks

  1. Realize the difference. You’re not calling the command. You’re calling something else. That was step one for me.
  2. See what options you have: type -a name | type -t name
  3. Add path for command
  4. Read help, not just man

Cases revisited

animated gif showing revisited kill case - that both shell built-in and command are available
animated gif showing revisited kill case – that both shell built-in and command are available
animated gif showing revisited time case - that both shell keyword and command are available
animated gif showing revisited time case – that both shell keyword and command are available
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s