zoukankan      html  css  js  c++  java
  • Linux_4/ |, (>, 2>, &>, >>, 2>>)

    ###1 重定向

    [root@localhost tmp]# ls -l 1-parameter.sh
    -rw-rw-r--. 1 zhxu zhxu 50 Nov  7 11:51 1-parameter.sh
    [root@localhost tmp]# ls -l 1-parameter.sh > 1.txt  #标准输出
    [root@localhost tmp]# ls -l 1-parametreeeeeeeeee.sh > 1.txt
    ls: cannot access 1-parametre.sh: No such file or directory
    [root@localhost tmp]# ls -l 1-parametre.sh 2> 1.txt  #错误输出
    [root@localhost tmp]# cat 1.txt
    ls: cannot access 1-parametre.sh: No such file or directory
    [zhxu@localhost tmp]$ ls -l ../tmp/ &> text  #正确和错误输出
    [zhxu@localhost tmp]$ ls -l ../tmpppp/ &>> text  #正确和错误输出
    [zhxu@localhost tmp]$ cat text
    total 0
    -rw-rw-r--. 1 zhxu zhxu 0 Nov 19 19:42 text
    ls: cannot access ../tmpppp/: No such file or directory
    [zhxu@localhost tmp]$

    ###2

    [root@localhost tmp]# wc -l < /etc/passwd  #读取文件内容的行数
    39
    [root@localhost tmp]#
    [root@localhost tmp]# wc -l  /etc/passwd  #读取文件,并读取行数
    39 /etc/passwd
    [root@localhost tmp]#

    ###3

    重定向:命令 文件

    管道符:命令 命令

    [root@localhost tmp]# echo "root" | passwd --stdin root  #任意门
    Changing password for user root.
    passwd: all authentication tokens updated successfully.
    [root@localhost tmp]#

    ------ 时间永远是公平的,你付出多少时间,时间就回报你多少。
  • 相关阅读:
    mysql相关
    java注解@Valid@Validated表单验证
    驼峰参数、下划线["_"]参数,属性互传
    redis,windows设置记录
    Java入门第一季学习总结
    计算属性calc()的运算规则
    swiper实现翻页,页面高度超出可滚动
    git常用命令
    Linux下svn常用命令
    图片高度不够一页,如何覆盖全屏
  • 原文地址:https://www.cnblogs.com/zhxu/p/9952495.html
Copyright © 2011-2022 走看看