vim常用操作与重定向
shell输入重定向和输出重定向
1.输出重定向
下面以/etc下的passwd为例,演示不同的重定向方式。(前提以普通用户身份执行,root不会输出错误信息)
find /etc -name passwd ##此条命令会输出一些正确和错误输出,用于下面演示
find /etc -name passwd > file ##以覆盖的方式重定向正确输出,'>'代表覆盖原文件的内容,'>>'代表追加输出到原内容后面
find /etc -name passwd 1> file ##以覆盖的方式重定向正确输出,1代表正确输出,'>'与'>>'同上)
find /etc -name passwd 2> file ##以覆盖的方式重定向错误输出
find /etc -name passwd &> file ##以覆盖的方式重定向全部输出
find: ‘/etc/pki/CA/private’: Permission denied(没有权限)
find: ‘/etc/pki/rsyslog’: Permission denied
find: ‘/etc/dhcp’: Permission denied
find: ‘/etc/lvm/archive’: Permission denied
find: ‘/etc/lvm/backup’: Permission denied
find: ‘/etc/lvm/cache’: Permission denied
find: ‘/etc/selinux/targeted/active’: Permission denied
find: ‘/etc/selinux/final’: Permission denied
find: ‘/etc/polkit-1/rules.d’: Permission denied
find: ‘/etc/polkit-1/localauthority’: Permission denied
find: ‘/etc/grub.d’: Permission denied
find: ‘/etc/redhat-access-insights’: Permission denied
find: ‘/etc/libvirt’: Permission denied
find: ‘/etc/ipsec.d’: Permission denied
find: ‘/etc/audisp’: Permission denied
find: ‘/etc/audit’: Permission denied
find: ‘/etc/firewalld’: Permission denied
find: ‘/etc/sudoers.d’: Permission denied
find: ‘/etc/virt-who.d’: Permission denied
/etc/passwd
linux重定向/etc/pam.d/passwd
find /etc -name passwd 2> file(重定向错误输出)
/etc/passwd
/etc/pam.d/passwd
find: ‘/etc/pki/CA/private’: Permission denied
find: ‘/etc/pki/rsyslog’: Permission denied
find: ‘/etc/audit’: Permission denied
find: ‘/etc/polkit-1/rules.d’: Permission denied
find: ‘/etc/polkit-1/localauthority’: Permission denied
find: ‘/etc/grub.d’: Permission denied
find: ‘/etc/selinux/targeted/modules/active’: Permission denied
find: ‘/etc/lvm/archive’: Permission denied
find: ‘/etc/lvm/backup’: Permission denied
find: ‘/etc/lvm/cache’: Permission denied
find: ‘/etc/dhcp’: Permission denied
find: ‘/etc/firewalld’: Permission denied
find: ‘/etc/audisp’: Permission denied
find: ‘/etc/sudoers.d’: Permission denied
find: ‘/etc/ipsec.d’: Permission denied
find: ‘/etc/libvirt’: Permission denied
find: ‘/etc/cups/ssl’: Permission denied
find /etc -name passwd &> file(重定向全部输出)
find: ‘/etc/pki/CA/private’: Permission denied
find: ‘/etc/pki/rsyslog’: Permission denied
find: ‘/etc/audit’: Permission denied
/etc/passwd
find: ‘/etc/polkit-1/rules.d’: Permission denied
find: ‘/etc/polkit-1/localauthority’: Permission denied
find: ‘/etc/grub.d’: Permission denied
find: ‘/etc/selinux/targeted/modules/active’: Permission denied
/etc/pam.d/passwd
find: ‘/etc/lvm/archive’: Permission denied
find: ‘/etc/lvm/backup’: Permission denied
find: ‘/etc/lvm/cache’: Permission denied
find: ‘/etc/dhcp’: Permission denied
find: ‘/etc/firewalld’: Permission denied
find: ‘/etc/audisp’: Permission denied
find: ‘/etc/sudoers.d’: Permission denied
find: ‘/etc/ipsec.d’: Permission denied
find: ‘/etc/libvirt’: Permission denied
find: ‘/etc/cups/ssl’: Permission denied
find /etc -name passwd >> file(以追加的方式将正确输出保存到file内容后面)
find /etc -name passwd 1>> file(以追加的方式将正确输出保存到file内容后面)
find /etc -name passwd 2>> file(以追加的方式将错误输出保存到file内容后面)
find /etc -name passwd 1> file1 >2 file2 (以覆盖的方式重定向正确输出保存到file1,错误输出保存到file2)
(这里只演示一个,其他同'>')
/etc/passwd
/etc/pam.d/passwd
find: ‘/etc/pki/CA/private’: Permission denied
find: ‘/etc/pki/rsyslog’: Permission denied
find: ‘/etc/dhcp’: Permission denied
find: ‘/etc/lvm/archive’: Permission denied
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论