$>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.

 
movie.mpeg.001 movie.mpeg.002 movie.mpeg.003 ... movie.mpeg.099
 
$cat movie.mpeg.0*>movie.mpeg
 
 
 

Examples:
cat f - g Output f's contents, then standard input, then g's contents.
cat Copy standard input to standard output.

$cat

标准输入默认从键盘读取内容,于是、、、、、、

 
$tail -f  实时查看文件

$ 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'

 
 
使用-f选项,tail将持续监视这个文件;一旦添加了新行,
新行将会立即显示在屏幕上。
 
【注意对文件更名的跟踪】
 
tee
【管道】
命令从标准输入到读取数据,并将数据发送到标准输出的能力,
是使用了shell特性中的管道。
 
 
Copy standard input to each FILE, and also to standard output.
 
一个T型管道。
 $ll|tee tee.t|grep t
 $ll|tee tee.t|grep t|sort|uniq|wc|tee tee.t.t
 
 
 
 
 
管道  
how to use pipes
http://tldp.org/HOWTO/Bash-Prog-Intro-HOWTO-4.html
 
 
 
 
 

file descriptor 0 1 2 一切皆文件 stdout stderr stdin /dev/null 沉默是金 pipes的更多相关文章

  1. 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   ...

  2. Linux Shell脚本入门--(linux空设备文件和重定向)>/dev/null 2>&1

    linux空设备文件和重定向 输出/输入重导向 >      >>   <   <<   :>   &>   2&>   2< ...

  3. 文件描述符(File Descriptor)简介

    本文转载自文件描述符(File Descriptor)简介 导语 维基百科:文件描述符在形式上是一个非负整数.实际上,它是一个索引值,指向内核为每一个进程所维护的该进程打开文件的记录表.当程序打开一个 ...

  4. Linux Shell 文件描述符 及 stdin stdout stderr 重定向

    Abstract: 1) Linux Shell 命令的标准输入.标准输出.标准错误,及其重定位: 2)Linux Shell 操作自定义文件描述符: 文件描述符是与文件相关联的一些整数,他们保持与已 ...

  5. shell基础知识之 stdin,stdout,stderr和文件描述符

    stdin,stdout,stderr stdin=0 stdout=1 stderr=2 使用tee来传递内容,把stdout 作为stdin 传到下个命令 root@172-18-21-195:/ ...

  6. [svc]linux中的文件描述符(file descriptor)和文件

    linux中的文件描述符(file descriptor)和文件 linux为了实现一切皆文件的设计哲学,不仅将数据抽象成了文件,也将一切操作和资源抽象成了文件,比如说硬件设备,socket,磁盘,进 ...

  7. 文件描述符file descriptor与inode的相关知识

    每个进程在Linux内核中都有一个task_struct结构体来维护进程相关的 信息,称为进程描述符(Process Descriptor),而在操作系统理论中称为进程控制块 (PCB,Process ...

  8. 无法获取指向控制台的文件描述符 (couldn't get a file descriptor referring to the console)

    背景 最近收拾东西,从一堆杂物里翻出来尘封四年多的树莓派 3B 主机来,打扫打扫灰尘,接上电源,居然还能通过之前设置好的 VNC 连上.欣慰之余,开始 clone 我的 git 项目,为它们拓展一个新 ...

  9. shell脚本0——”一切皆文件“, 认识Shell

    一.”一切皆文件“与“管道” 1)管道:grep foo /path/to/file | grep -n -k 3 | more 实际过程与我们直观认为的相反,最好通过实际过程理解.首先运行的是mor ...

随机推荐

  1. canvas绘制视频封面--摘抄

    一.需求:上传视频,同时截取视频某一帧作为视频的封面. 二.实现思路:利用canvas绘制图像的功能,绘制图像某一帧,这里绘制了第一帧,很简单就实现了. 三.代码: <!DOCTYPE html ...

  2. 反汇编->C++虚函数深度分析

    先来查看一简单例子 #include<iostream> using namespace std; class Base{ public: virtual void f() { cout ...

  3. javascript解决小数的加减乘除精度丢失的方案

    原文:http://www.jb51.net/article/85463.htm function accDiv(arg1,arg2){ var t1=0,t2=0,r1,r2; try{t1=arg ...

  4. yii执行流程

    yii执行流程 原文:http://www.cnblogs.com/bluecobra/archive/2011/11/30/2269207.html 一 目录文件 |-framework     框 ...

  5. js-解决移动端点击事件的延迟问题

    众所周知,在手机上的点击事件会有延迟300ms的问题.但在做手机端某些点击小游戏时,我们就需要取消这个延迟的问题: 第一步:禁止页面的缩放 <meta name="viewport&q ...

  6. Cryptography I 学习笔记 --- 流密码

    1. 对于一次性密码本(one time pad),没有唯密文攻击(cypher text only attack),也就是说如果攻击者只能拿到密文,他什么也做不了 2. 完美密码:密钥长度大于密文长 ...

  7. PAT 甲级 1045 Favorite Color Stripe(DP)

    题目链接 Favorite Color Stripe 题意:给定$A$序列和$B$序列,你需要在$B$序列中找出任意一个最长的子序列,使得这个子序列也是$A$的子序列 (这个子序列的相邻元素可以重复) ...

  8. CDOJ_149 解救小Q

    原题网址:http://acm.uestc.edu.cn/#/problem/show/149 小Q被邪恶的大魔王困在了迷宫里,love8909决定去解救她. 迷宫里面有一些陷阱,一旦走到陷阱里,就会 ...

  9. luogu P2746 [USACO5.3]校园网Network of Schools

    题目描述 一些学校连入一个电脑网络.那些学校已订立了协议:每个学校都会给其它的一些学校分发软件(称作“接受学校”).注意即使 B 在 A 学校的分发列表中, A 也不一定在 B 学校的列表中. 你要写 ...

  10. 0.从零开始搭建spring mvc + mybatis + memcached+ dubbo\zookper的maven项目

    1.首先创建maven 项目,配置相关pom信息 2.配置spring mvc 4, 测试,提交代码 3.引入配置mybatis3,测试,提交代码 4.配置事务,测试,提交代码 5.配置memcach ...