shell programming 1

1. Several Commands

wc: get a count of the total number of lines, words, characters contained in file.

Options:
	-l: to count the number of lines in a file
	-c: to count the number of characters in a file
    -w: to count the number of words in a file
ln: create duplicate name for a given file

Usages: ln from to

Options:
	-s: create a symbolic link points to original file; if the original file is removed, the symbolic link no longer works.
	* if a symbolic link doesn't work, which should be removed unless you have a specific reason to keep it around.

Points:
	ln files directory: you can create links to a bunch of files within a specific target directory using the format.

2. Standard Input/Output & I/O Redirection

symbol usage
[1]> override the destination file with standard ouputs
2> override the destination file with error outputs
&> override the destination file with standard & error outputs
>> append inputs at the end of destination file
< regard destination file as the part of command
<< define the end characters of file(eg. EOF)

3. Shell

I. Unix System: Kernal + Utilities

II. Command Execution Procedure

  1. search programs in specified PATH
  2. the shell creates a clone of itself(subshell)
  3. the shell asks the kernal to replace subshell
  4. the kernal copies programs into memroy
  5. start executing

4. Regular Expressions

  1. The caret(^): matching the beginning of the line
  2. The dollar sign($): matching the end of the line
  3. Other symbols:
symbol usage
* to match zero or more characters
?/. any single character
any character enclosed between the brackets
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章