linux怎么查看本机内存大小
235
2022-11-10
io 重定向
文件描述符:
[root@centos7 ~]#cp /etc/hosts /data [root@centos7 ~]#ll /proc/$$/fd total 0 lrwx------ 1 root root 64 Feb 6 09:26 0 -> /dev/pts/0 lrwx------ 1 root root 64 Feb 6 09:26 1 -> /dev/pts/0 lrwx------ 1 root root 64 Feb 6 09:26 2 -> /dev/pts/0 lrwx------ 1 root root 64 Feb 6 09:26 255 -> /dev/pts/0 自定义文件描述符: [root@centos7 ~]#exec 8<>/data/hosts [root@centos7 ~]#!?ll ll /proc/$$/fd total 0 lrwx------ 1 root root 64 Feb 6 09:26 0 -> /dev/pts/0 lrwx------ 1 root root 64 Feb 6 09:26 1 -> /dev/pts/0 lrwx------ 1 root root 64 Feb 6 09:26 2 -> /dev/pts/0 lrwx------ 1 root root 64 Feb 6 09:26 255 -> /dev/pts/0 lrwx------ 1 root root 64 Feb 6 09:27 8 -> /data/hosts 1668 取消文件描述符 [root@centos7 ~]#exec 8>&- [root@centos7 ~]#ll /proc/$$/fd total 0 lrwx------ 1 root root 64 Feb 6 09:26 0 -> /dev/pts/0 lrwx------ 1 root root 64 Feb 6 09:26 1 -> /dev/pts/0 lrwx------ 1 root root 64 Feb 6 09:26 2 -> /dev/pts/0 lrwx------ 1 root root 64 Feb 6 09:26 255 -> /dev/pts/0
linux 给程序提供三种io 设备:
标准输入:0
标准输出:1 默认输出终端窗口
标准错误:2 默认输出终端窗口
[root@centos7 ~]#tty /dev/pts/0 [root@centos7 ~]#ls > /dev/pts/1 [root@centos7 ~]#tty /dev/pts/1 [root@centos7 ~]#1 Centos-7.repo Documents f1.bak index.html index.html.2 Pictures Templates 2 Desktop Downloads f1.bak0 index.html.1 Music Public Videos
标准错误输出:
[root@centos7 data]#cmd 2> /data/f3.out [root@centos7 data]#cat /data/f3.out bash: cmd: command not found... Similar command is: 'mcd'
分类重定向:
ls /error /data/ > f1 2>f2
错误/标准 输出到 f1
ls /error /data >>all.log 2>&1 (注意顺序)
ls /error /data &>all.log
[root@centos7 data]#cat all.log ls: cannot access /error: No such file or directory /data: all.log err.log f1 f1.out f2.out f3.out hosts hostsbak httpd-2.4.6-80.el7.centos.x86_64.rpm repodata
[root@centos7 data]#ls /error /data &>all.log
[root@centos7 data]#cat all.log ls: cannot access /error: No such file or directory /data: all.log err.log f1 f1.out f2.out f3.out hosts hostsbak httpd-2.4.6-80.el7.centos.x86_64.rpm repodata
cmd > log 2&>1 cmd 2&>1 >log (正确的重定向到log 中,错误标准输出) cmd &>log cmd 2>log >&2
(ls;pwd) > all.log
hostname > /dev/null (吸收屏幕的过程)
echo $passwd |passwd --stdin sun &> /dev/null
标准输入:
cat
cat < /etc/hosts
tr命令:
man tr
-c 取反
-d delete
-s 压缩
-t
tr ‘a-z’ ‘A-Z’< /etc/hosts > f1
tr "abcd" "1234"
tr -d "abc"
tr -dc "adc"
[root@centos7 data]#tr -dc "adc" adweca122 adca[root@centos7 data]#
tr -s " " 压缩
tr --hlep
tr "\n" "\t" 换行 tab
tr -d "\r" 回车
tr -s " " ":" 多行重定向: [root@centos7 data]#mail -s "hello" sun < mail 管道:转换大小写: ls /boot/ /error 2&>1 |tr "a-z" "A-Z" ls /boot/ /error |& tr "a-z" "A-Z" df |tr " " ":" echo {1..100} |tr " " "+" |bc seq -s + 1 100 |bc [root@centos7 data]#seq -s + 1 100 |bc
5050 -s, --separator=STRING use STRING to separate numbers (default: \n) tar -cvf - /home |tar -xvf - (测试命令) tee: w |tee -a ls.log |tr -d "\n" 作用: lsb_release -a centos6 操作系统 echo $user root ascii: man 7 ascii
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
发表评论
暂时没有评论,来抢沙发吧~