Difference between revisions of "Bash Builtin Commands"

From Free Knowledge Base- The DUCK Project: information for everyone
Jump to: navigation, search
(printf)
Line 14: Line 14:
 
   printf "%s\n" "Hello World"  
 
   printf "%s\n" "Hello World"  
  
 
+
see: [[printf bash builtin]]
  
  

Revision as of 13:26, 9 February 2014

Bash has several commands that are built inside the command shell. When the name of a builtin command is used as the first word of a simple command, the shell executes the command directly, without invoking another program. Builtin commands are necessary to implement functionality impossible or inconvenient to obtain with separate utilities. Many of the builtins have been extended by POSIX or Bash.

alias, bg, bind, break, builtin, caller, cd, command, compgen, complete, compopt, continue, declare, dirs, disown, echo, enable, eval, exec, exit, export, false, fc, fg, getopts, hash, help, history, jobs, kill, let, local, logout, mapfile, popd, printf, pushd, pwd, read, readonly, return, set, shift, shopt, source, suspend, test, times, trap, true, type, typeset, ulimit, umask, unalias, unset, wait

printf

The printf command provides a method to print pre-formatted text, expanding shells script standard output over the echo command. See format and example below:

 printf <FORMAT> <ARGUMENTS...>
 printf "Last name: %s\nName: %s\n" "$SURNAME" "$LASTNAME"

the printf does not automatically line feed unlike the echo command. LF is not implied, it must be stated. See two equivalents below:

 echo "Hello World"
 printf "Hello World\n"
 printf "%s\n" "Hello World" 

see: printf bash builtin