Article directory
1. Parameters (P17 44 48)
- Positional parameters: use ${10} for more than 9
- $*: more than 9 parameters
- $@:
- $$: process ID number
- $?: Displays the last exit status of the command
- $* and $@:
#直接使用echo 两者无区别
#输入变量“dog cat” apple
for i in "$@"; do
echo $i
done
for i in "$*"
do
echo $i
done
#输出:
===============$@=================
dog cat
apple
================$*================
dog cat apple
-
If there are more than 9 parameters:
1. ${10}
2. Use the shift command, such as:
If shift is 3:
2. > < redirection
cat < a.sh > b.sh
or: cat a.sh> b.sh
standard output > or (1>)
standard error 2>
standard input 0 <
&> standard output and standard error
3. Special files
/dev/null : Empty the file and determine whether the id who exists
/dev/zero: create an empty temporary swap file
/dev/tty: similar to entering the password after sudo, not displayed on the terminal
4、grep
1. Obtain process information (ps -eLf): ps -eLf | grep firefox
2. Type
grep: BRE
↓ Extended
egrep: ERE
fgrep: interpret all characters literally, no special meaning
3. Parameters
-c display the total number of matching lines
-o only display the matching content
-A num If the match is successful, print the matching line and the next n lines together
-B num If the match is successful, print the matching line and the first n lines together
-C num If the match is successful, print the matching line and n lines before and after it
-v display unmatched lines
-w match word
5. Linux file type
normal file | - |
---|---|
Table of contents | d |
character device file | c |
block device file | b |
socket file | s |
symbolic link file | l |