标签:inf ansi 导出文件 vertica flow log ossh bsp dai
数据流重导向
# 例子标准输出,导出到文件
[dai@workPC ~]$ ll / > ~/rootfile
[dai@workPC ~]$ cat rootfile
total 80
lrwxrwxrwx. 1 root root 7 Mar 7 2019 bin -> usr/bin
dr-xr-xr-x. 6 root root 4096 Dec 31 19:36 boot
drwxr-xr-x 2 root root 4096 Mar 12 2019 data
drwxr-xr-x 19 root root 3000 Oct 13 08:27 dev
drwxr-xr-x. 107 root root 12288 Dec 31 19:37 etc
drwxr-xr-x. 4 root root 4096 Dec 1 23:54 home
lrwxrwxrwx. 1 root root 7 Mar 7 2019 lib -> usr/lib
lrwxrwxrwx. 1 root root 9 Mar 7 2019 lib64 -> usr/lib64
drwx------. 2 root root 16384 Mar 7 2019 lost+found
drwxr-xr-x. 2 root root 4096 Apr 11 2018 media
drwxr-xr-x. 2 root root 4096 Apr 11 2018 mnt
drwxr-xr-x. 11 root root 4096 Dec 30 21:16 opt
dr-xr-xr-x 103 root root 0 Oct 13 08:27 proc
dr-xr-x---. 10 root root 4096 Jan 1 12:05 root
drwxr-xr-x 34 root root 1160 Dec 31 19:37 run
lrwxrwxrwx. 1 root root 8 Mar 7 2019 sbin -> usr/sbin
drwxr-xr-x. 2 root root 4096 Apr 11 2018 srv
dr-xr-xr-x 13 root root 0 Jan 1 20:01 sys
drwxrwxrwt. 16 root root 12288 Jan 1 12:53 tmp
drwxr-xr-x. 13 root root 4096 Mar 7 2019 usr
drwxr-xr-x. 19 root root 4096 Mar 7 2019 var
# 标准错误输入,导出到黑洞
# /dev/null 垃圾桶黑洞装置与特殊写法
[dai@workPC /]$ cd root/
-bash: cd: root/: Permission denied
[dai@workPC home]$ cd root/ 2> /home/dai/error1.log
[dai@workPC ~]$ cat error1.log
-bash: cd: root/: No such file or directory
# /dev/null 垃圾桶黑洞装置与特殊写法
[dai@workPC /]$ cd root/ 2> /dev/null
[dai@workPC /]$
# 将错误和正确信息一起导出文件中, 比如下面的这个例子,如果权限不够的时候,屏幕会输出错误信息
# 这个时候将正确和错误信息都输出到 file_name 这个文件
find /home -name .bashrc > file_name 2>&1
# 引子
[dai@workPC ~]$ cat > rootfile
wqe
we2
^C
[dai@workPC ~]$ cat rootfile
wqe
we2
[dai@workPC ~]$
# 下面就是input的用法
# 将一个文件作为另一个文件的输入
[dai@workPC ~]$ cat > rootfile < ~/.bashrc # 将.bashrc 文件中的内容导入 rootfile
# 使用关键字给文件插入文字
[dai@workPC ~]$ cat > rootfile << eof
> This is a test
> OK now stop
> eof
[dai@workPC ~]$ cat rootfile
This is a test
OK now stop
[dai@workPC ~]$ echo hello world;echo dai;echo haolong
# 不考虑指令是否执行成功
cmd1&&cmd2
# 如果cmd1 正确执行,再执行cmd2;如果cmd1执行失败,则不再执行cmd2
cmd1||cmd2
# 如果cmd1 正确执行,不再执行cmd2;如果cmd1执行失败,再执行cmd2
标签:inf ansi 导出文件 vertica flow log ossh bsp dai
原文地址:https://www.cnblogs.com/dadaizi/p/13060421.html