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]#

    ------ 时间永远是公平的,你付出多少时间,时间就回报你多少。
  • 相关阅读:
    Springboot学习:核心配置文件
    Springboot学习:底层依赖与自动配置的原理
    Springboot学习:介绍与HelloWorld
    js根据时间戳倒计时
    windows phone 豆瓣api的封装
    Android开发初始
    PHP(一)
    程序员修炼之道(一)
    WebClient和HttpReuqest两种网络请求的方式
    黑客与画家(二)
  • 原文地址:https://www.cnblogs.com/zhxu/p/9952495.html
Copyright © 2011-2022 走看看