file descriptor 0 1 2 一切皆文件 stdout stderr stdin /dev/null 沉默是金 pipes
$>emtry_or_create_a_file.f
$ll>>append_a_file.f
standard output input error
$ls -l /usr/bin >ok.txt 标准输出文件有内容 运行正确的结果信息
$ls -l /bin/usr 2 >ok.txt 标准输出文件有内容 运行错误信息
0 input
1 output
2 error
$ls -l /bin/usr >emptry.txt 标准输出文件无内容 不会将结果输出 缺少文件描述符中的2
将标准输出和标准错误重定向到一个文件的2种办法
$ll /bin/usr >o.f 2>&1
$ll /bin/usr & > o.f
标准错误将重定向到屏幕
$ll /bin/usr 2>&1>o.f
不希望的到输出
$ll /bin/usr 2 >/dev/null
$x 2>/dev/null
https://en.wikipedia.org/wiki/Null_device
In programmer jargon, especially Unix jargon, it may also be called the bit bucket[2] or black hole.
Examples:
cat f - g Output f's contents, then standard input, then g's contents.
cat Copy standard input to standard output.
$cat
标准输入默认从键盘读取内容,于是、、、、、、
$ tail --help
Usage: tail [OPTION]... [FILE]...
Print the last 10 lines of each FILE to standard output.
With more than one FILE, precede each with a header giving the file name.
With no FILE, or when FILE is -, read standard input.
Mandatory arguments to long options are mandatory for short options too.
-c, --bytes=[+]NUM output the last NUM bytes; or use -c +NUM to
output starting with byte NUM of each file
-f, --follow[={name|descriptor}]
output appended data as the file grows;
an absent option argument means 'descriptor'
-F same as --follow=name --retry
-n, --lines=[+]NUM output the last NUM lines, instead of the last 10;
or use -n +NUM to output starting with line NUM
--max-unchanged-stats=N
with --follow=name, reopen a FILE which has not
changed size after N (default 5) iterations
to see if it has been unlinked or renamed
(this is the usual case of rotated log files);
with inotify, this option is rarely useful
--pid=PID with -f, terminate after process ID, PID dies
-q, --quiet, --silent never output headers giving file names
--retry keep trying to open a file if it is inaccessible
-s, --sleep-interval=N with -f, sleep for approximately N seconds
(default 1.0) between iterations;
with inotify and --pid=P, check process P at
least once every N seconds
-v, --verbose always output headers giving file names
-z, --zero-terminated line delimiter is NUL, not newline
--help display this help and exit
--version output version information and exit
NUM may have a multiplier suffix:
b 512, kB 1000, K 1024, MB 1000*1000, M 1024*1024,
GB 1000*1000*1000, G 1024*1024*1024, and so on for T, P, E, Z, Y.
With --follow (-f), tail defaults to following the file descriptor, which
means that even if a tail'ed file is renamed, tail will continue to track
its end. This default behavior is not desirable when you really want to
track the actual name of the file, not the file descriptor (e.g., log
rotation). Use --follow=name in that case. That causes tail to track the
named file in a way that accommodates renaming, removal and creation.
GNU coreutils online help: <http://www.gnu.org/software/coreutils/>
Report tail translation bugs to <http://translationproject.org/team/>
Full documentation at: <http://www.gnu.org/software/coreutils/tail>
or available locally via: info '(coreutils) tail invocation'
file descriptor 0 1 2 一切皆文件 stdout stderr stdin /dev/null 沉默是金 pipes的更多相关文章
- file descriptor 0 1 2 一切皆文件 stdout stderr stdin /dev/null 沉默是金 pipes 禁止输出 屏蔽 stdout 和 stderr 输入输出重定向 重定向文件描述符
movie.mpeg.001 movie.mpeg.002 movie.mpeg.003 ... movie.mpeg.099 $cat movie.mpeg.0*>movie.mpeg ...
- Linux Shell脚本入门--(linux空设备文件和重定向)>/dev/null 2>&1
linux空设备文件和重定向 输出/输入重导向 > >> < << :> &> 2&> 2< ...
- 文件描述符(File Descriptor)简介
本文转载自文件描述符(File Descriptor)简介 导语 维基百科:文件描述符在形式上是一个非负整数.实际上,它是一个索引值,指向内核为每一个进程所维护的该进程打开文件的记录表.当程序打开一个 ...
- Linux Shell 文件描述符 及 stdin stdout stderr 重定向
Abstract: 1) Linux Shell 命令的标准输入.标准输出.标准错误,及其重定位: 2)Linux Shell 操作自定义文件描述符: 文件描述符是与文件相关联的一些整数,他们保持与已 ...
- shell基础知识之 stdin,stdout,stderr和文件描述符
stdin,stdout,stderr stdin=0 stdout=1 stderr=2 使用tee来传递内容,把stdout 作为stdin 传到下个命令 root@172-18-21-195:/ ...
- [svc]linux中的文件描述符(file descriptor)和文件
linux中的文件描述符(file descriptor)和文件 linux为了实现一切皆文件的设计哲学,不仅将数据抽象成了文件,也将一切操作和资源抽象成了文件,比如说硬件设备,socket,磁盘,进 ...
- 文件描述符file descriptor与inode的相关知识
每个进程在Linux内核中都有一个task_struct结构体来维护进程相关的 信息,称为进程描述符(Process Descriptor),而在操作系统理论中称为进程控制块 (PCB,Process ...
- 无法获取指向控制台的文件描述符 (couldn't get a file descriptor referring to the console)
背景 最近收拾东西,从一堆杂物里翻出来尘封四年多的树莓派 3B 主机来,打扫打扫灰尘,接上电源,居然还能通过之前设置好的 VNC 连上.欣慰之余,开始 clone 我的 git 项目,为它们拓展一个新 ...
- shell脚本0——”一切皆文件“, 认识Shell
一.”一切皆文件“与“管道” 1)管道:grep foo /path/to/file | grep -n -k 3 | more 实际过程与我们直观认为的相反,最好通过实际过程理解.首先运行的是mor ...
随机推荐
- MSB与LSB Big Endian Little Endian
Most Significant Bit, Last(Least) Significant Bit 最高有效位(MSB) 指二进制中最高值的比特.在16比特的数字音频中,其第1个比特便对16bit的字 ...
- serializeObject 的应用
function sendForm() { var invOrderModelWrapper = {}; // 头 var objHeader = $('#invOrderForm').seriali ...
- AC日记——网络最大流 洛谷 P3376
题目描述 如题,给出一个网络图,以及其源点和汇点,求出其网络最大流. 输入输出格式 输入格式: 第一行包含四个正整数N.M.S.T,分别表示点的个数.有向边的个数.源点序号.汇点序号. 接下来M行每行 ...
- 关于Java的TreeMap
今天写代码的时候需要做这样的一件事情 从一个文件中读取数据,得到数百万个含有time,uid,text的对象,去重之后再根据time排序 第一反应是使用TreeMap 重载了equals和hashCo ...
- 小程序 之使用HMACSHA1算法加密报文
首先说说我们前端常用的加密技术, 我们常用的加密技术有:如MD5加密,base64加密 今天要说的是HMACSHA1加密技术 先介绍下什么是SHA1算法, 安全哈希算法(Secure Hash Alg ...
- Codeforces 600E Lomsat gelral (树上启发式合并)
题目链接 Lomsat gelral 占坑……等深入理解了再来补题解…… #include <bits/stdc++.h> using namespace std; #define rep ...
- 转载:P2P技术原理及应用(1)
转帖allen303allen的空间 作 者:金海 廖小飞 摘要:对等网络(P2P)有3种主要的组织结构:分布式哈希表(DHT)结构.树形结构.网状结构.P2P技术已 经延伸到几乎所有的网络应用领域, ...
- bzoj 1835/luogu P2605 : [ZJOI2010]base 基站选址
题目描述 有N个村庄坐落在一条直线上,第i(i>1)个村庄距离第1个村庄的距离为Di.需要在这些村庄中建立不超过K个通讯基站,在第i个村庄建立基站的费用为Ci.如果在距离第i个村庄不超过Si的范 ...
- java常用组件
一.Jpanel 1.面板:容器类组件 2.用途:与Layout配合使用,JFrame—>JPanel—>Layout 二.JTextField 1.文本框 2.JPasswordFiel ...
- SpringUtils写法
@Componentpublic class SpringUtils implements ApplicationContextAware { @Override public void setApp ...