More on Redirection
- command >&2 used to redirect command output to <std_err>
- command &> filename used to redirect both <std_out> and <std_err> to filename
- command <<PATTERN Input from <std_in> until a line with just PATTERN is found.
Functions
- Functions are command sequences that can be created and run on demand.
- They are not scripts and do not rely on the setting of your $PATH variable.
- The can be loaded from a file when you login or created at the command line.
Function Syntax
The return Command
The return command can be used to exit from a function without exiting from your shell.
- It can be followed by an digit which will serve as the return code.
- Example: return 2
The type Command
The type command can be used to determine the type of a command and where the code for it is stored.
- type who
- Output: who is /usr/bin/who
- type cd
- Output: cd is a shell builtin
- type my_fun
- Output: my_fun is a function (followed by the function code)