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——MySQL用户与数据库的关系
    Kafka——Kakfa的设计思想
    Hibernate建表——将MySQL的JSON列映射到Java字段(Jpa/Hibernate——Java)
    Spring Boot——Apache Commons包作用说明
    word转html工具
    html导出word
    html导出pdf
    获取dubbo-admin.war(自己maven编译)
    ajax提交表单中文呈现乱码解决
    JVM优化
  • 原文地址:https://www.cnblogs.com/zhxu/p/9952495.html
Copyright © 2011-2022 走看看