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
search programs in specified PATH
the shell creates a clone of itself(subshell)
the shell asks the kernal to replace subshell
the kernal copies programs into memroy
start executing
4. Regular Expressions
The caret(^): matching the beginning of the line
The dollar sign($): matching the end of the line
Other symbols:
symbol usage
* to match zero or more characters
?/. any single character
…
any character enclosed between the
brackets
~来了小老弟
原创文章 74获赞 288访问量 2万+
关注
评论0