Bash Script 11: Internal Bash Builtins

Published On: Wednesday, November 14th 2018
Bash has a lot of builtins, or internal functions, you can call. While most of them are very similar to utility programs available, the distinction is that no additional process is spawned. It may not sound like much, but a linux operating system has a limit to the number of processes that can run. If a server happens to run out of processes, but you still have a terminal open, then you still have a way to work with the system.

I/O builtins

In previous bash script posts, I've used the echo function. Here are some examples of that and more: [bash] # echo something to the screen echo "something to the screen" # read in from the keyboard, line-by-line while read LINE; do #Do some processing here echo "$LINE" done # read in file.txt, line-by-line while read LINE < file.txt; do #Do some processing here echo "$LINE" done # append to file.txt echo "Appending a line to the end" >> file.txt # echo a formatted line COUNT=1 NAME="Barry" printf "Hi %s! The count is %d" "$NAME" "$COUNT" [/bash]

Filesystem builtins

Bash also provides many of the fs builtins used every day. [bash] # Change directory cd /dir/to/enter # List dir contents ls -l # Print the current directory pwd [/bash] There are many more bash builtins than I've listed here, but these are the most commonly used.

Tag Cloud

Copyright © 2026 Barry Gilbert.