Académique Documents
Professionnel Documents
Culture Documents
2. Environment
Visible to all shells Examples: PATH, HOME, TERM, SHELL
Variable Substitution
Syntax: $variablename
Variable Substitution
The use of an absolute path name for the value of variable that references a file or directory allows you to be anywhere in the file hierarchy and still access the desired file or directory.
$ $ $ $ $ $
Command Substitution
Used to replace a command with its output within the same command line
Syntax: $(command)
Examples:
$ $ $ $ $ $ $
Tilde Substitution
If a word begins with a tilde (~), tilde expansion is performed on that word. RULES: A tilde by itself or in front of a / is replaced by the path name set in the HOME variable $ echo $HOME $ echo ~ A tilde followed by a + is replaced with the value of the PWD variable $ cd tree $ echo $PWD $ ls ~+/tree
Tilde substitution
A tilde followed by a replaced with the value of the OLDPWD variable $ echo $OLDPWD $ ls ~ -
Transferring local variables to the environment Syntax: $ export variable Example: $ n=5 $ export n
ps Command
$ ps [-options]
use to check the PID and then kill the process if it is taking too long or has stopped
ps Command Output
-First identity the PID of the lowest level unresponsive process -Sometimes necessary to kill the Parent of process and on rare occasions even the Parent of the Parent -Killing a parent process will kill all child processes spawned by it -Look at output to be able to trace from the child up the hierarchy to the parent processes that spawned them
Terminating Processes
File name generating characters will never generate a file name that has a leading dot The leading dot in dot files must be explicitly provided
Examples: $ ls a
. .. .zz abc abcd bbabb cyz zzayy abcdef abcz
matched Examples: $ls a . .. .zz 1G 2G 7G 15G Ant Cat Dog abc abcdef ba cyz $ls [abc]??? $ls [1-9][A-Z] $ls [!A-Z]??
Review
$ ls a . Abc e35f .. Abcd efg .test1 abc fe3f .test2 abcdemf fe3fg Given the directory, list all file names that 1. Contain only 5 characters 2. Contain at least 5 characters 3. Begin with an a or an A 4. Have at least 4 characters and begin with an a or an A 5. End with a sequence e, a single number, and an f 6. Begin with a dot 7. Begin with a dot, except . 8. Begin with a dot, except . and . .