Shell command miscellaneous

1.> test.txt redirection, execution of this command will clear the content of test.txt.

2. Pay attention to the difference between the following two commands

for i in 'cat test.txt' ; do echo $i  done

  The output result is cat test.txt

for i in `cat test.txt` ; do echo $i  done

  Assuming that the content in test.txt is abc, the output result is abc, ``will tell bash to take the execution result of this command as a parameter.

3. When any command is executed, a time can be added in front of it to count the running time of this command.

4. Each open process has a file descriptor stored under the pid/fd of /proc/process, and $$ is the pid of the current process. If the handle of a file is not released, even if the file is deleted, the content of the file is still there, just copy the file descriptor. When a file FD has not been released, deleting the original file will not affect the FD

5. exec number Num<> file name uses file descriptor Num to open the file

6, exec Num<&- close the current file handle Num

7. Once the public key authentication is implemented, there is no need to interact. The interaction here means that you don't need to enter the user name and password when logging in to the machine. This is described in detail in the previous article.

8. Expect is an interpreter. The grammatical meaning is, what to do when there is something, an example is as follows:

#注意语义是出现什么怎么处理,当出现“yes/no”的时候执行后面的操作
expect {
        "yes/no" {send "yes\r"; exp_continue }
        "password:" { send "centos\r" };
}
#下面一行是结束的标志
expect eof

 

Guess you like

Origin blog.csdn.net/xiaoan08133192/article/details/109177962