A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.geeksforgeeks.org/linux-unix/builtin-command-in-linux-with-examples/ below:

builtin command in Linux with examples

builtin command in Linux with examples

Last Updated : 14 Oct, 2024

The builtin command in shell scripting is used to execute a shell builtin, passing it arguments, and also retrieving its exit status. Its primary use is to ensure that you can call the original functionality of a builtin command even when a function with the same name is defined.

Syntax
builtin [shell-builtin [arg ..]]

where,

Linux builtin command Example

Here’s a simple example of using the builtin command:

Scenario: You want to create a function named cd, but still want to use the original cd functionality within that function.

Here, we are creating a function to replace the 'cd' command. When you will use cd() function it will change the directory to the desktop directly.

In this case, every time you use cd, it will move to the Desktop directory, but the functionality of the original cd command is retained by using builtin.

Key Option Used with the builtin Command builtin --help Command

The builtin --help command displays help information for the builtin command.

This will output detailed help information regarding the builtin command, listing available builtins and their functionality.

Conclusion

The builtin command is particularly useful when you want to override a shell builtin (e.g., cd, echo, test) with a custom function while still being able to access the original builtin behavior. It ensures that the core functionality remains intact within your custom shell functions.



RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4