CSCI 1730 - Week 09 Topics
CSCI 1730 - Week 09 Topics Overview
- Systems Programming Overview (continued)
- File I/O
User UNIX Interface: SHELL
- Command line interface between user and system.
- Automatically starts upon login.
- Enables the execution of other programs.
- Supports a command language for commands, programming, and shell scripting.
- Offers variables, loops, conditionals, etc.
- Processes user commands and may call system calls to complete operations.
Various UNIX Shells
- Common UNIX shells:
- bash: Default shell used (e.g., in Odin).
- sh: Bourne shell.
- ksh: Korn shell.
- csh: C shell.
- zsh: Z Shell.
- Differences primarily related to scripting and aliasing.
- Example bash command:
for i in {1..10}; do echo $i; done (not compatible with csh).
Environment Variables
- Consists of variables used by the shell for operations:
- Variable Structure: Name and Value.
- View current list with
env command. - To display a specific variable's value, use:
echo $<var_name>. - Notable variables:
HOME: User's home directory.PATH: Executable search path.USER: Current user.HOSTNAME: System hostname.PWD: Current working directory.
Setting Environment Variables
- Setting a variable uses:
- For bash/ksh:
<name>=<value>. - For tcsh:
setenv <name> <value>.
- Examples:
PS1=myprompt>: Custom prompt.PATH=$PATH:$HOME: Appending home to PATH.DATE=$(date): Store current date time.
Aliases
- Provides shorthand for frequently used commands:
- Syntax:
- For ksh/bash:
alias <shortcut>=<command>. - For tcsh:
alias <shortcut> <command>. - Examples:
- `alias ll=