《初入linux》--第三部分-man命令与输入输出
来源:互联网 发布:淘宝搜索词分析收费 编辑:程序博客网 时间:2024/05/21 22:45
#######man的使用方法#######
manual 手册 用man命令查询帮助
man有9个级别,针对同名不同性质的文件用不同级别查询。
1)系统命令
2)内核所给接口
3)程序所给接口
4) /dev中特殊设备文件
5)一般文件
6)游戏
7)系统软件包
8)系统管理命令
9)内核信息
例:在/bin和/etc中都有passwd,
man 1 passwd 查看passwd命令的手册man 5 passwd 查看/etc/passwd的手册
man中的快捷方式
上/下健 上下逐行换
pageup/pagedown 翻页
d | u 上下半个屏幕
G / gg 最末,开头
/ 关键字 搜索并高亮显示
q 退出
##########输入输出##########
在普通用户下执行
find /etc -name passwd
输出
find: ‘/etc/pki/CA/private’: Permissiondeniedfind: ‘/etc/pki/rsyslog’: Permission deniedfind: ‘/etc/audit’: Permission denied/etc/passwd ###正确输出find: ‘/etc/polkit-1/rules.d’: Permissiondeniedfind: ‘/etc/polkit-1/localauthority’:Permission deniedfind: ‘/etc/dhcp’: Permission deniedfind:‘/etc/selinux/targeted/modules/active’: Permission deniedfind: ‘/etc/lvm/archive’: Permission deniedfind: ‘/etc/lvm/backup’: Permission deniedfind: ‘/etc/lvm/cache’: Permission deniedfind: ‘/etc/grub.d’: Permission denied/etc/pam.d/passwd ###正确输出find: ‘/etc/audisp’: Permission deniedfind: ‘/etc/firewalld’: Permission deniedfind: ‘/etc/cups/ssl’: Permission deniedfind: ‘/etc/ipsec.d’: Permission deniedfind: ‘/etc/libvirt’: Permission deniedFile: /home/kiosk/Desktop/第三讲 Page 2 of 4find: ‘/etc/sudoers.d’: Permission deniedfind: ‘/etc/named’: Permission denied其中有标注的为正确输出,其余为错误输出。
那么问题就来了,我们仅仅看到输出的内容,我们还需要管理输出的内容,是我们更清晰的得到想要的结果
如何管理输出,首先介绍输入输出所用到的符号:
1.重定向 < >
> 重定向正确输出
2> 重定向错误输出
&> 重定向所有信息
例: find /etc -name passwd > file
将/etc下所有名称与passwd有关的信息全部写入file文件中,并覆盖file原有内容
注:> 2> &> 都会覆盖源文件的内容
> file 表示清空文件
2.追加符 >> <<
>> 追加正确信息
2>> 追加错误信息
&>> 追加所有信息
注:追加符不会覆盖信息,而是把相应内容增加在文件最后
例:
find/etc -name passwd > file ####重定向正确输出 find/etc -name passwd 2> file ####重定向错误输出 find/etc -name passwd &> file ####重定向所有输出 find/etc -name passwd >> file ###追加正确输出 find/etc -name passwd 2>> file ####追加错误输出 find/etc -name passwd &>> file ####追加输出 find/etc -name passwd > file 2>&1 ####重新定义错误输出为正确
3.管道符 |
将前一条命令的此输出作为后一条命令的输入
例:find /etc -name passwd | wc -l
[root@localhost mnt]# find /etc -name passwd | wc -l2找到/etc下与passwd有关的内容并统计其行数
注:管道符可以连用,以实现某些较复杂的特殊输出。
如:输出由 cat -b /etc/passwd 结果中若干行的第22-29行
此时连用管道符,无需知道总共多少行,先输出前29行,cat -b /etc/passwd | head -29 输出后29-22=8行,cat -b /
/passwd | head -29 | tail -8
tee命令
tee 将输出复制到指定文件 如:cal| tee /home/test
注:管道的某些特殊用法
由于管道只能通过正确信息输出所以,要输出所有信息,必须使用 2>&1 将错误信息转化后从管道输入
2>&1 表示将错误信息当作正确信息
|tee
复制一份输出
2>&1 |
转换错误输出为正确再通过管道
- 《初入linux》--第三部分-man命令与输入输出
- 《初入linux》--第一部分-基本命令符
- 《初入linux》--第十四部分-shell 脚本命令
- 第三单元man命令
- 《初入linux》--第六部分-用户与文件权限
- 《初入linux》--第十部分-设备使用与时间同步
- 鸟哥的Linux私房菜基础学习篇(第三版)之第五章:首次登入与在线求助man page(略)
- 第29周-鸟哥的Linux私房菜基础篇第三版-第五章 首次登入与在线求助 man page
- Linux MAN命令
- linux man命令使用方法
- Linux中的man命令
- linux man 命令 详解
- Linux man 命令解读
- linux man命令闲聊
- linux man 命令 详解
- linux man命令详解
- linux man 命令 详解
- linux man命令
- android studio开发<十一> Library第三方类库源码, Jar包和SO库
- stm32 换了芯片出现了很多错误
- mybatis简单入门
- 【NOIP2016提高A组五校联考4】square
- 《机器管家》的生产者‘北安公司’原来是在我们公司总部取的景
- 《初入linux》--第三部分-man命令与输入输出
- iOS中UITextField使用详解
- Linux_USB_gadget设备驱动
- 使用Nexus搭建Maven私服
- 关于webapp的浏览记录写法
- MySQL的查询、子查询及连接查询
- <context annotation-config />标签意义:
- 缓存问题
- Mysql分表数据通过Shell进行导出与统计