zoukankan      html  css  js  c++  java
  • Linux_几个符号命令

    一、管道符号 | (将前面命令的输出结果传给后面的命令)

    [eRrsr@hadoop09-linux ~]$ cat /etc/passwd | grep "^root"
    root:x:0:0:root:/root:/bin/bash

    二、重定向符号 [>] [<]

    [root@hadoop09-linux ~]# df > /usr/tmp/df.txt # >:输入重定向 即将命令结果重定向给df.txt,需要root权限,df.txt若不存在则新建
    [root@hadoop09-linux ~]# cat /usr/tmp/df.txt 
    Filesystem           1K-blocks      Used Available Use% Mounted on
    /dev/sda2             18339256   2757204  14650468  16% /
    tmpfs                   506272        72    506200   1% /dev/shm
    /dev/sda1               297485     33538    248587  12% /boot
    /dev/sr0               4251346   4251346         0 100% /media
    [root@hadoop09-linux ~]# wc -l < /usr/tmp/df.txt  # <:输出重定向 即将df.txt输出给wc命令 -l:统计行数
    5
    [root@hadoop09-linux ~]# pwd > /dev/null       # 若要执行命令,但不要求输出,可以重定向到/dev/null
    [root@hadoop09-linux ~]# 

    三、追加符号 [>>] [<<]

    [root@hadoop09-linux ~]# df >> /usr/tmp/df.txt 
    [root@hadoop09-linux ~]# cat /usr/tmp/df.txt 
    Filesystem           1K-blocks      Used Available Use% Mounted on
    /dev/sda2             18339256   2757204  14650468  16% /
    tmpfs                   506272        72    506200   1% /dev/shm
    /dev/sda1               297485     33538    248587  12% /boot
    /dev/sr0               4251346   4251346         0 100% /media
    Filesystem           1K-blocks      Used Available Use% Mounted on
    /dev/sda2             18339256   2757208  14650464  16% /
    tmpfs                   506272        72    506200   1% /dev/shm
    /dev/sda1               297485     33538    248587  12% /boot
    /dev/sr0               4251346   4251346         0 100% /media
    [root@hadoop09-linux ~]# cat << eof   # eof 文档起点
    > hello Linux               # 文档内容第一行
    > Linux: Hello eRrsr           # 文档内容第二行
    > eof                   # eof 文档终点 
    hello Linux
    Linux: Hello eRrsr

    四、预执行符 ``(反引号ESC下面)

    [root@hadoop09-linux tmp]# ll `find /etc -name init -a  -type f -a -size +5`
    -rwxr-xr-x. 1 root root 4781 Oct 29  2009 /etc/kdump-adv-conf/kdump_initscripts/init

    五、家目录 ~

    [root@hadoop09-linux ~]# pwd
    /root
    [root@hadoop09-linux ~]# su - eRrsr
    [eRrsr@hadoop09-linux ~]$ pwd
    /home/eRrsr
  • 相关阅读:
    【Android】Android如何实现手机震动
    【Android】详解Android的menu菜单
    【Smali】Smali文件的动态调试
    【C#】C#项目如何获得项目的根目录
    【Android】Android如何对APK签名
    【Android】Android如何对APK反编译
    【SqlServer】在SqlServer中把数据导入导出为Excel文件
    【C#】解析C#中JSON.NET的使用
    【C#】浅析C#中的日期处理
    TCP与UDP传输协议
  • 原文地址:https://www.cnblogs.com/eRrsr/p/5848839.html
Copyright © 2011-2022 走看看