1. I/O重定向

  默认情况下,有3个“文件”处于打开状态,stdin,stdout,stderr;重定向的解释:捕捉一个文件,命令,程序,脚本或者脚本中的代码块的输出,然后将这些输出作为输入发送到另一个文件,命令,程序或者脚本中。

  每个打开的文件都会被分配一个文件描述符,stdin,stdout,stderr的文件描述符分别是0,1,2.除了这3个文件,对于其他需要打开的文件,保留文件描述符3~9.在某些情况下,将这些额外的文件描述符分配给stdin,stdout或stderr作为临时的副本链接也是非常有用的。在经过复杂的重定向和刷新之后需要把他们恢复成正常状态。可以使用shell内建ulimit -n查看最大文件描述符,一般未1024.

ulimit描述如下:

              -a     All current limits are reported
              -b     The maximum socket buffer size
              -c     The maximum size of core files created
              -d     The maximum size of a process's data segment
              -e     The maximum scheduling priority ("nice")
              -f     The maximum size of files written by the shell and its children
              -i     The maximum number of pending signals
              -l     The maximum size that may be locked into memory
              -m     The maximum resident set size (many systems do not honor this limit)
              -n     The maximum number of open file descriptors (most systems do not allow this value to be set)
              -p     The pipe size in 512-byte blocks (this may not be set)
              -q     The maximum number of bytes in POSIX message queues
              -r     The maximum real-time scheduling priority
              -s     The maximum stack size
              -t     The maximum amount of cpu time in seconds
              -u     The maximum number of processes available to a single user
              -v     The maximum amount of virtual memory available to the shell and, on some systems, to its children
              -x     The maximum number of file locks
              -T     The maximum number of threads
    
View Code

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-06-22
  • 2021-10-18
  • 2021-08-24
  • 2022-01-22
  • 2022-03-07
  • 2022-12-23
猜你喜欢
  • 2021-11-29
  • 2021-10-09
  • 2022-01-31
  • 2021-11-10
相关资源
相似解决方案