Abstract:

1) Linux Shell 命令的标准输入、标准输出、标准错误,及其重定位;

2)Linux Shell 操作自定义文件描述符;

文件描述符是与文件相关联的一些整数,他们保持与已打开文件的关联。众所周知的文件描述符是标准输入stdin、标准输出stdout、标准错误stderr,我们可以重定位这些文件描述符关联文件的内容到另外一个文件文件描述符。

1. Linux Shell 命令的标准输入、标准输出、标准错误

当我们在编写 shell 脚本时,我们会非常频繁地操作执行命令的标准输入stdin、标准输出stdout、标准错误stderr。过滤 shell 脚本或者执行命令的输出信息并且把它们重定位到特定的地方,成了我们分析脚本执行情况的必要工作。当我们执行脚本文件或者执行一个 shell 命令的时候,单从终端输出我们很难区分哪些是标准输出,哪些是标准错误。然而,我们把这些信息重定向特定的地方,以便于我们分析脚本文件及 shell 命令的执行情况。

文件描述符是与打开文件或者数据流相关联的整数,0、1、2 是系统保留的三个文件描述符,分别对应标准输入、标准输出、标准错误。
Linux Shell 使用 " > "  ">>"  进行对文件描述符进行重定位。
">"  与 ">>"  的作用是不一样的,前者使用本次输出内容替换原有文件的内容,后者则是把本次输出追加到原文件的后面。

在对文件描述符进行详细分析之前,先执行以下命令,为后面的实验操作准备一些必要的文件:

  1. echo -e "\e[42;31m --- Prepare resource file ---\e[0m";
  2. echo "This is example text 1." > temp.txt;
  3. echo "This is example text 2." >> temp.txt;
  4. cat temp.txt;
  5. echo "a1" > a1;
  6. echo "a2" > a2;
  7. echo "a3" > a3;
  8. sudo chmod 000 a3;
  9. ls -alF a*;

1.1 获取 Linux Shell 命令执行结果

Linux Shell 中每一条 shell 命令的执行都有返回值,用以返回命令的执行结果。
在命令执行结束后,通过引用 $? 获取最后一条命令执行的返回值,当返回值为零代表命令执行成功。

  1. echo -e "\e[42;31m --- Get command execution result! ---\e[0m";
  2. ls + ;
  3. echo -e "\e[1;32m --- 'ls + ' executed and return value is: $? \e[0m";
  4. ls -alF ./ ;
  5. echo -e "\e[1;32m --- 'ls -alF ./' executed and return value is: $? \e[0m";



由于 “ ls + ” 的输入参数 “ + ”是一个 “ls” 命令不能接受的参数,所以由上面的执行结果可以看到命令执行的错误信息以及命令执行的返回值为: 2 ;
接下来的命令 “ls -alF” 是一条合法的命令,所以,我们看到它成功执行的返回值为:0 ;

重定位运算符 ">" ">>" 的默认参数为标准输出 stdout ,即 1 ;
所以 ">" 等价于 "1>"; ">>" 等价于 "1>>"

1.2 Linux Shell 标准输出 stdout 的重定位

  1. echo -e "\e[42;31m --- Redirect stdout ! ---\e[0m";
  2. ls + > out.txt;
  3. echo -e "\e[1;32m --- 'ls + > out.txt' executed and return value is: $? \e[0m";
  4. echo -e "\e[1;32m --- Contents of out.txt as following descriptions:\e[0m \e[1;33m";
  5. cat out.txt;
  6. echo -e "\e[0m";
  7. rm out.txt;


由实验结果可以看出标准输出 stdout 重定向输出文件 out.txt 的内容为空;
因为 “ ls + ”命令的输入参数 “+” 为非法参数,所以命令执行失败,没有输出结果,并且同时看到命令执行返回值为: 2 ,非零,表示执行失败。

1.3 Linux Shell 标准错误 stderr 的重定位

  1. echo -e "\e[42;31m --- Redirect stderr ! --- \e[0m";
  2. ls + 2> out.txt;
  3. echo -e "\e[1;32m 'ls + 2> out.txt' executed and return value is: $? \e[0m";
  4. echo -e "\e[1;32m Contents of out.txt as following descriptions:\e[0m \e[1;33m";
  5. cat out.txt;
  6. echo -e "\e[0m";
  7. rm out.txt;

由实验结果看出非法命令 "ls + 2> out.txt" 的执行并没有任何的输出,与之前的姐果一样;
不同的是,错误信息也没有在命令执行的时候输出到终端上面,而是被重定向到了文件 out.txt 里面;

1.4 Linux Shell 分别重定向标准输出 stdin 与标准错误 stderr 到指定的文件:

  1. echo -e "\e[42;31m --- Redirect stdout and stderr to exclusive files ! ---\e[0m";
  2. cat a* 2>stderr.txt 1>stdout.txt;
  3. echo -e "\e[1;32m'cat a* 2>stderr.txt 1>stdout.txt' executed and return value is: $? .\e[0m";
  4. echo -e "\e[1;32mContents of stderr.txt is:\e[0m \e[1;33m";
  5. cat stderr.txt;
  6. echo -e "\e[0m";
  7. echo -e "\e[1;32mContents of stdout.txt is:\e[0m \e[1;33m";
  8. cat stdout.txt;
  9. echo -e "\e[0m";
  10. rm stderr.txt stdout.txt;



这次的执行中无论是标准输出 stdout 与标准错误 stderr 都没有在命令执行时输出到终端上,只是分别输出到 stdout.txt 与 stderr.txt 中;
由于 a3 是一个没有读、写、执行命令权限的文件,所以当 cat a3 的时候就会有错误信息输出到 stderr.txt ;
a1、a2 则把文件内容输出到 stdout.txt ;

1.5 Linux Shell 重定向标准错误到标准输出:

1.5.1 使用 " 2>&1" 把标准错误 stderr 重定向到标准输出 stdout ;

  1. echo -e "\e[42;31m --- Redirect stderr to stdout approach first! ---\e[0m";
  2. cat a* > output.txt 2>&1;
  3. echo -e "\e[1;32m'cat a* 2>&1 output.txt' executed and return value is: $?\e[0m";
  4. echo -e "\e[1;32mContents of output.txt is:\e[0m \e[1;33m";
  5. cat output.txt;
  6. echo -e "\e[0m";
  7. rm output.txt;


由上面的实验结果看出, 无论是标准输出 stdin 还是标准错误 stderr ,都被重定向到了 output.txt 里面。

1.5.2 使用 "&>" 把标准错误 stderr 重定向到标准输出 stdout ;

  1. echo -e "\e[42;31m --- Redirect stderr to stdout approach second ! ---\e[0m";
  2. cat a* &> output.txt;
  3. echo -e "\e[1;32m'cat a* &> output.txt' executed and return value is: $?\e[0m";
  4. echo -e "\e[1;32mContents of output.txt is:\e[0m \e[1;33m";
  5. cat output.txt;
  6. echo -e "\e[0m";
  7. rm output.txt


由实验结果,标准错误 stderr 被转化为标准输出 stdout ,并重定向到了 output.txt 中;

1.6 把标准错误 stderr 重定向到 /dev/null 

  1. echo -e "\e[42;31m --- Redirect stderr to /dev/null ! ---\e[0m";
  2. cat a* 2>/dev/null;
  3. echo -e "\e[1;32m'cat a* 2>/dev/null' executed and return value is $?\e[0m";



"/dev/null" 是一个特殊的设备文件,所有输入到其中的比特流都会被丢弃;
由实验结果看出,标准输出如常输出到终端上,而标准错误则没有输出,被重定位到 "/dev/null" 。

1.7 使用 tee 命令,实现重定向与终端双输出

当我们使用重定向输出时,所有信息都被重定向输出到我们指定的文件描述符,终端上面就再也看不到这些信息了;
我们可以通过 tee 命令,实现把信息重定向输出到文件的同时输出到终端,附上 tee 的使用说明:

tee 命令会从标准输出接受信息,把信息保存到指定的文件同时,把信息输出到标准输出;

1.7.1 把标准输出 stdout 重定向到 tee 的标准输入 stdin :

  1. echo -e "\e[42;31m --- Redirect stdout as stdin of tee! --- \e[0m";
  2. cat a* | tee out.txt | cat -n;
  3. echo -e "\e[1;32m'cat a* | tee out.txt | cat -n' executed and return value is: $?\e[0m";
  4. echo -e "\e[1;32mContents of out.txt is:\e[0m \e[1;33m";
  5. cat out.txt;
  6. echo -e "\e[0m";
  7. rm out.txt;



"cat a*" 的标准输出 stdout 通过pipe( "|" )重定向为 tee 的标准输入;
tee 把这些信息重定向到 out.txt 的同时,输出到 tee 的标准输出 stdout ;
tee 的标准输出通过 pipe("|") 重定向到了 "cat -n" 的标准输入;

所以以上实验结果应该这样看:
1)因为pipe("|") 只处理标准输出的信息,所以 cat a3 的错误信息依旧在终端直接输出,没有被重定向处理;
2)tee 从它的标准输入 stdin 只接收到 a1、a2 的内容,所以我们通过 "cat -n" 给输出信息加上行号来标识出 tee 接收到的信息;
3)再通过查看 out.txt 文件,发现 tee 命令输出到 out.txt 的信息,与 "cat -n"的信息是一致的;

1.7.2 把标准错误 stderr 转换成标准输出 stdout ,一同输出到 tee 的标准输入,以便把所有信息重定向到文件的同时,输出到终端:

  1. echo -e "\e[42;31m --- Redirect stdout burden with stderr as stdin of tee! --- \e[0m";
  2. cat a* 2>&1 | tee out.txt | cat -n;
  3. echo -e "\e[1;32m'cat a* 2>&1 | tee out.txt | cat -n' executed and return value is: $?\e[0m"
  4. echo -e "\e[1;32mContents of out.txt is:\e[0m \e[1;33m";
  5. cat out.txt;
  6. echo -e "\e[0m";
  7. cat a* 2>&1 | tee -a out.txt | cat -n;
  8. echo -e "\e[1;32m'cat a* 2>&1 | tee -a out.txt | cat -n' executed and return value is: $?\e[0m"
  9. echo -e "\e[1;32mContents of out.txt is:\e[0m \e[1;33m";
  10. cat out.txt;
  11. echo -e "\e[0m";
  12. rm out.txt;



前面提到的 " 2>&1 " 参数可以把命令的标准错误转换为标准输出,这里利用一下,举个实用的例子,呵呵!
tee 命令会把输出文件之前的内容冲掉,再把自己的输出信息输出到文件,但可以使用 " -a " 参数,实现追加方式把信息重定向到指定文件。

1.8 重定位标准输入 stdin 

1.8.1 把重定向的标准输入作为命令的输入参数:

先来看看我们貌似已经十分熟悉的 cat 命令的帮助,不知道各位是否留意到有这样一招,反正我之前是没有留意到,呵呵!!!

原来 cat 使用 "-" 作为参数,就是把它接受的标准输入stdin 直接输出到它的标准输出;
呵呵!只能说之前学艺不精,没看到啊!
这里也学会了一点,就是在看linux 下命令的 help 时,我们要多加留心一下是否接受 stdin ;
如果接受 stdin 作为输入,这些命令的扩展用法就可以多好多咯。。。
好,言归正传,来一段实践代码再说,有图有真相嘛,呵呵!!!

  1. echo -e "\e[42;31m --- Use stdin as a command argument ! --- \e[0m";
  2. ls -alF | cat;
  3. echo -e "\e[1;32m'ls -alF | cat' executed and return value is: $?\e[0m"
  4. ls -alF | cat -;
  5. echo -e "\e[1;32m'ls -alF | cat -' executed and return value is: $?\e[0m";
  6. ls -alF | cat -n;
  7. echo -e "\e[1;32m'ls -alF | cat -n' executed and return value is: $?\e[0m";
  8. ls -alF | cat /dev/stdin;
  9. echo -e "\e[1;32m'ls -alF | cat /dev/stdin' executed and return value is: $?\e[0m"




这里要提提的就是 "-" 等价于 /dev/stdin ,你懂的。。。

1.8.2 从文件重定向 shell 命令的标准输入:

Linux Shell 使用 "cmd < FILE " 的方式从一个文件重定向命令的标准输入;

  1. echo -e "\e[42;31m --- Redirect stdin from file ! --- \e[0m";
  2. cat < a1
  3. echo -e "\e[1;32m'cat < a1' executed and return value is: $?\e[0m";
  4. cat - < a2;
  5. echo -e "\e[1;32m'cat - < a2 executed and return value is: $?\e[0m";
  6. cat /dev/stdin < temp.txt;
  7. echo -e "\e[1;32m'cat /dev/stdin < temp.txt' executed and return value is: $?\e[0m";



上面的 3 条执行命令把 a1、a2、a3 三个文件的内容重定向到命令的标准输入 stdin 。

1.8.3 把文本块重定向为 shell 命令的标准输入 stdin :

有时候,我们需要把一个文本块(多行的文本)重定向给一个 shell 命令作为标准输入。
我们假设有这样一种情况,文本块来源于一个 shell 执行脚本里面,在这个 shell 脚本执行的时候,需要把这个文本块输出到一个文件;
如这样一个例子,一个 shell 脚本需要把它的执行 log 写到一个文件里面,
在文件的开头,需要加入几行信息作为这个 log 文件的开头用以注释一下这个文件,我们可以如下操作:

  1. echo -e "\e[42;31m --- Redirecting from a text block to a file within a script! --- \e[0m";
  2. cat <<EOF>log.txt
  3. Hello
  4. EOF
  5. echo -e "\e[1;32m'cat < log.txt Hello world! EOF' executed and return value is: $?\e[0m";
  6. echo -e "\e[1;32mContents of log.txt as following: \e[0m \e[1;33m";
  7. cat log.txt;
  8. echo -e "\e[0m";
  9. echo -e "\e[42;31m --- Redirecting from a text block to append into a file within a script! --- \e[0m";
  10. cat <<EOF >> log.txt
  11. Nice to meet
  12. EOF
  13. echo -e "\e[1;32m'cat <> log.txt Nice to meet you! EOF' executed and return value is $?\e[0m";
  14. echo -e "\e[1;32mContents of log.txt as following: \e[0m \e[1;33m";
  15. cat log.txt;
  16. echo -e "\e[0m";
  17. rm log.txt;



1)使用 "<text block   EOF" 的形式把一个 text block 重定向到一个 shell command 的标准输入;
2)上述实验把 text block 重定向给 cat 命令的标准输入, cat 再把它自己的标准输出 stdout 重定向到 log.txt ;
3)上述实验采取了 "> log.txt" 与 ">> log.txt" 两种方式对 cat 的标准输出 stdout 进行重定向到 log.txt ,
    前者是重新创建文件进行信息的输出,后者是以追加的方式进行重定向输出;

2. 用户自定义文件描述符:

现在我们知道 0、1、2是 shell 保留的文件描述符;
另外,我们还可以定义自己的文件描述符,并对其进行读写;
用户自定义文件描述符使用 "exec" 命令进行创建;
用户自定义文件描述符的创建有三种形式:
    1)只读方式的文件描述符;
    2)截断模式创建写方式的文件描述符;
    3)追加模式创建写方式的文件描述符;

2.1 以读方式创建文件描述符:

使用 " exec descriptor<file Name 的模式创建只读模式的用户自定义文件描述符;
使用 "&descriptor" 的模式引用文件描述符;
只读方式的文件描述符只能读取一次,要再次读取,需要对文件描述符重新打开赋值;
 

  1. echo -e "\e[42;31m --- Create a file descriptor for reading file! --- \e[0m";
  2. exec 3<a1;
  3. echo -e "\e[1;32m'exec 3<a1' executed="" to="" create="" a="" file="" descriptor="" 3="" for="" reading="" and="" return="" value="" is:="" $?="" ---\e[0m"<="" span="">;
  4. echo -e "\e[1;32mContents of a1 as following output:\e[0m \e[1;33m";
  5. cat <&3;
  6. echo -e "\e[0m";
  7. echo -e "\e[1;32mContents of a1 with file descriptor 3 to read again as following output:\e[0m \e[1;33m";
  8. cat <&3;
  9. echo -e "\e[0m";



如实验结果,当我们再次打开文件对文件描述符重新赋值之前,我们再次使用文件描述符 3 对文件进行读取时,没有任何输出内容。

2.2 以截断模式创建写方式的文件描述符:

所谓截断模式,就是相当于重新创建文件,文件之前的内容将会丢失;
使用 " exec descriptor>file Name 的模式创建截断模式的用户自定义的写方式的文件描述符;
使用 "&descriptor" 的模式引用文件描述符;
写方式的文件描述符只要一次打开便可多次写入,并且后续的写入操作会一直追加到文件的结尾,但是文件打开之前的内容就会丢失

  1. echo -e "\e[42;31m --- Create a file descriptor for writing file in truncation mode!\e[0m";
  2. echo -e "\e[1;32mContents of a2 before writing it as following output: \e[0m \e[1;33m";
  3. cat a2;
  4. echo -e "\e[0m";
  5. exec 4>a2;
  6. echo -e "\e[1;32m 'exec 4>a2' executed to create a file descriptor 4 for writing.\e[0m";
  7. echo "newline in truncation mode" >&4;
  8. echo -e "\e[1;32m 'echo \"newline in truncation mode\" >&4' executed and return value is: $?\e[0m";
  9. echo -e "\e[1;32mContents of a2 after writing in truncation mode as follwing output: \e[0m \e[1;33m";
  10. cat a2;
  11. echo -e "\e[0m";
  12. echo "newline in truncation mode 2" >&4;
  13. echo -e "\e[1;32m 'echo \"newline in truncation mode 2\" >&4' executed and return value is: $?\e[0m";
  14. echo -e "\e[1;32mContents of a2 after writing twice in truncation mode as follwing output: \e[0m \e[1;33m";
  15. cat a2;
  16. echo -e "\e[0m";
  17. exec 4>a2;
  18. echo -e "\e[1;32m 'exec 4>a2' executed to reassign file descriptor 4 for writing\e[0m";
  19. echo "newline in truncation mode 3" >&4;
  20. echo -e "\e[1;32m 'echo \"newline in truncation mode 3\" >&4' executed and return value is: $?\e[0m";
  21. echo -e "\e[1;32mContents of a2 after reassign its file descriptor for writing in truncation mode: \e[0m \e[1;33m";
  22. cat a2;
  23. echo -e "\e[0m";


由上述实验结果可以看到,我们引用 "&4" 文件描述符,并且对其进行多次写入,后面的写入内容会追加到之前写入信息的后面;
当我们对文件描述符进行再次打开后,再引用 "&4" 文件描述符,并且对其进行写入,发现之前两次写入的内容已经丢失,只剩下最后一次写入的信息了。

2.3 以追加模式创建写方式的文件描述符:

所谓追加模式,就是打开文件进行写操作,文件之前的内容不会丢失,写操作写入的内容以追加方式添加到文件的末尾;
使用 " exec descriptor>>file Name 的模式创建追加模式的用户自定义的写方式的文件描述符;
使用 "&descriptor" 的模式引用文件描述符;
写方式的文件描述符只要一次打开便可多次写入,并且后续的写入操作会一直追加到文件的结尾;

  1. echo -e "\e[42;31m --- Create a file descriptor for writing file in append mode!\e[0m";
  2. echo -e "\e[1;32mContents of temp.txt before writing it as following output: \e[0m \e[1;33m";
  3. cat temp.txt;
  4. echo -e "\e[0m";
  5. exec 5>>temp.txt;
  6. echo -e "\e[1;32m 'exec 5>>temp.txt' executed to create a file descriptor 5 for appending.\e[0m";
  7. echo "newline in append mode" >&5;
  8. echo -e "\e[1;32m 'echo \"newline in append mode\" >&5' executed and return value is: $?\e[0m";
  9. echo -e "\e[1;32mContents of temp.txt after writing in append mode as follwing output: \e[0m \e[1;33m";
  10. cat temp.txt;
  11. echo -e "\e[0m";
  12. echo "newline in append mode 2" >&5;
  13. echo -e "\e[1;32m 'echo \"newline in append mode 2\" >&5' executed and return value is: $?\e[0m";
  14. echo -e "\e[1;32mContents of temp.txt after writing twice in append mode as follwing output: \e[0m \e[1;33m";
  15. cat temp.txt;
  16. echo -e "\e[0m";
  17. exec 5>>temp.txt;
  18. echo -e "\e[1;32m 'exec 5>>temp.txt' executed to reassign file descriptor 5 for writing: $?\e[0m";
  19. echo "newline in append mode 3" >&5;
  20. echo -e "\e[1;32m 'echo \"newline in append mode 3\" >&5' executed and return value is: $?\e[0m";
  21. echo -e "\e[1;32mContents of temp.txt after reassign its file descriptor for writing in append mode: \e[0m \e[1;33m";
  22. cat temp.txt;
  23. echo -e "\e[0m";

Linux Shell 文件描述符 及 stdin stdout stderr 重定向的更多相关文章

  1. Linux的文件描述符

    (1).文件描述符的定义 文件描述符是内核为了高效管理已被打开的文件所创建的索引,用于指向被打开的文件,所有执行I/O操作的系统调用都通过文件描述符:文件描述符是一个简单的非负整数,用以表明每个被进程 ...

  2. linux中文件描述符

    :: # cat ping.txt PING baidu.com (() bytes of data. bytes from ttl= time=32.1 ms bytes from ttl= tim ...

  3. shell 文件描述符

    /tmp/test.sh > /tmp/test.log 2>&1 这个命令的意思是 前半部分是将shell的输出重定向到/tmp/test/log.默认是标准输出(stdout文 ...

  4. shell文件描述符和重定向

    1.文件描述符是与一个打开的文件或数据流相关联的整数.文件描述符0,1,2是系统预留的. 0 --------stdin(标准输入) 1 --------stdout(标准输出) 2--------- ...

  5. linux下文件描述符的介绍

    当某个程序打开文件时,操作系统返回相应的文件描述符,程序为了处理该文件必须引用此描述符.所谓的文件描述符是一个低级的正整数.最前面的三个文件描述符(0,1,2)分别与标准输入(stdin),标准输出( ...

  6. 对于Linux中文件描述符的疑问以及解决

    问题 ​ 每次web服务器或者是几乎所有Linux服务器都需要对文件描述符进行调整,我使用ulimit -n来查看当前用户的最多能打开的文件,默认设置的是1024个,但是系统运行起来以及开启一些简单的 ...

  7. Linux中文件描述符fd和文件指针flip的理解

    转自:http://www.cnblogs.com/Jezze/archive/2011/12/23/2299861.html 简单归纳:fd只是一个整数,在open时产生.起到一个索引的作用,进程通 ...

  8. Linux下文件描述符

    http://blog.csdn.net/kumu_linux/article/details/7877770 文件描述符是一个简单的整数,用以标明每一个被进程所打开的文件和socket.第一个打开的 ...

  9. linux 最大文件描述符fd

    使用四种框架分别实现百万websocket常连接的服务器 著名的 C10K 问题提出的时候, 正是 2001 年.这篇文章可以说是高性能服务器开发的一个标志性文档,它讨论的就是单机为1万个连接提供服务 ...

随机推荐

  1. Ubuntu 设置内核版本的GRUB默认启动

    注:我只是一只小小的搬运工.这篇文章内容摘自: https://www.calazan.com/how-to-set-an-older-kernel-version-as-the-default-in ...

  2. MYSQL:alter语句中change和modify的区别

    您可以使用CHANGE old_col_namecolumn_definition子句对列进行重命名.重命名时,需给定旧的和新的列名称和列当前的类型.例如:要把一个INTEGER列的名称从a变更到b, ...

  3. iOS 字符串 MD5

    iOS 字符串 MD5 Objective-C 实现 需要引入头文件 #import <CommonCrypto/CommonCrypto.h> 这里用方法实现 + (nullable N ...

  4. 从好用到更好用 —— 2017 年又拍云 CDN 功能更新回顾

    又拍云一直致力于为客户带来更好的服务,在 2017 年又拍云 CDN 服务进行了数次重大更新,在功能上更加全面.完善,进一步提升了 CDN 的稳定性与安全性. 在过去一年里又拍云 CDN 服务共进行了 ...

  5. hihoCoder #1094 : Lost in the City(枚举,微软苏州校招笔试 12月27日 )

    #1094 : Lost in the City 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 Little Hi gets lost in the city. He ...

  6. hdu_1045Fire Net(二分图匹配)

    hdu_1045Fire Net(二分图匹配) 标签: 图论 二分图匹配 题目链接 Fire Net Time Limit: 2000/1000 MS (Java/Others) Memory Lim ...

  7. TCP为什么需要3次握手与4次挥手(转载)

    为什么需要“三次握手” 在谢希仁著<计算机网络>第四版中讲“三次握手”的目的是“为了防止已失效的连接请求报文段突然又传送到了服务端,因而产生错误”.在另一部经典的<计算机网络> ...

  8. [国嵌笔记][025][ARM指令分类学习]

    算术和逻辑指令 1.mov 格式:mov {条件}{s} <dest>, <op> 作用:把一个值从一个地方移动到另一个地方,<dest>必须是寄存器 示例: @m ...

  9. JavaScript实现职责链模式

    什么是职责链模式 职责链模式的定义是:使多个对象都有机会处理请求,从而避免请求的发送者和接收者之间的耦合关系,将这些对象连成一条链,并沿着这条链传递该请求,直到有一个对象处理它为止.举个例子:当你从公 ...

  10. 从零开始学习前端开发 — 18、BFC

    一. BFC的概念 BFC--block formating context的缩写,中文译为"块级格式化上下文" 二.如何触发BFC 1.设置float除none以外的值(left ...