zoukankan      html  css  js  c++  java
  • Linux

    三. 文件系统中跳转

    pwd - Print name of current working directory
    
    cd - Change directory
    
    ls - List directory contents
    
    pwd — 打印出当前工作目录名
    
    cd — 更改目录
    
    ls — 列出目录内容
    

    四. 探究操作系统

    ls – List directory contents
    
    file – Determine file type
    
    less – View file contents
    
    ls — 列出目录内容
    
    file — 确定文件类型
    
    less — 浏览文件内容
    

    五. 操作文件和目录

    cp – Copy files and directories
    
    mv – Move/rename files and directories
    
    mkdir – Create directories
    
    rm – Remove files and directories
    
    ln – Create hard and symbolic links
    
    cp — 复制文件和目录
    
    mv — 移动/重命名文件和目录
    
    mkdir — 创建目录
    
    rm — 删除文件和目录
    
    ln — 创建硬链接和符号链接
    
    通配符	
    rm 命令用到通配符(除了仔细检查输入的内容外!), 用 ls 命令来测试通配符 例如 rm * -> ls *
    

    六. 使用命令

    type – Indicate how a command name is interpreted
    
    type – 说明怎样解释一个命令名
    
    which – Display which executable program will be executed
    
    which – 显示会执行哪个可执行程序
    
    man – Display a command’s manual page
    
    man – 显示命令手册页
    
    apropos – Display a list of appropriate commands
    
    apropos – 显示一系列适合的命令
    
    info – Display a command’s info entry
    
    info – 显示命令 info
    
    whatis – Display a very brief description of a command
    
    whatis – 显示一个命令的简洁描述
    
    alias – Create an alias for a command
    
    alias – 创建命令别名
    

    七. 重定向

    >重定向标准输出 
    如果要删除一个文件,有一个技巧:> a         a为要被删除的文件
    重定向时,目标文件总是从开头被重写。错误信息不能输出到标准输出,重定向操作开始
    重写文件,然后由于错误而停止,导致文件内容删除。
    >> 追加
    
    
    重定向标准错误
    标准输入、输出和错误,shell 内部分别将其称为文件描述符0、1和2
    因为标准错误和文件描述符2一样,我们用这种 表示法来重定向标准错误
    ls -al /usr/bin1 2> a
    
    
    重定向标准输出和错误到同一个文件
    旧版本shell:
    ls -l /usr/bin > a 2>&1
    ls -l /usr/bin1 > a 2>&1
    首先重定向标准输出到文件 a,然后 重定向文件描述符2(标准错误)到文件描述符1(标准输出)
    使用表示法2>&1
    新版本shell:
    ls -l /usr/bin1 &> a
    
    
    重定向标准输入
    cat - Concatenate files
    cat < a.txt
    如果就输入cat, 默认会从标准输入读取数据,又标准输入默认链接到键盘。
    
    sort - Sort lines of text
    
    管道线pipelines( | )
    一个命令的标准输出可以通过pipelines送至另外一个命令的标准输入
    例如ls -l /usr/bin | less
    
    
    过滤器:把几个命令放在一起组成一个管道线
    例如:把目录/bin 和/usr/bin 中 的可执行程序都联合在一起,再把它们排序,然后浏览执行结果
    ls /bin /usr/bin | sort | less
    
    
    uniq - Report or omit repeated lines
    uniq 命令经常和 sort 命令结合在一起使用
    ls /bin /usr/bin | sort | uniq | less
    ls /bin /usr/bin | sort | uniq -d | less
    
    
    grep - Print lines matching a pattern
    ls /bin /usr/bin | sort | uniq | grep zip
    
    
    wc - Print newline, word, and byte counts for each file
    ls /bin /usr/bin | sort | uniq | wc -l
    
    
    head - Output the first part of a file
    tail - Output the last part of a file
    默认情况打10行。例如-n 5 打印5行
    
    tail -f 继续监测文件
    
    
    tee - Read from standard input and write to standard output and files
    tee 程序从标准输入读入数据,并且同时复制数据 到标准输出(允许数据继续随着管道线流动)		和一个或多个文件。当在某个中间处理 阶段来捕捉一个管道线的内容时,这很有帮助。
    在 grep 过滤管道线的内容之前,来捕捉整个目录列表到文件 ls.txt
    ls /usr/bin | tee ls.txt | grep zip
    
    
    
    cat - 连接文件
    
    sort - 排序文本行
    
    uniq - 报道或省略重复行
    
    grep - 打印匹配行
    
    wc - 打印文件中换行符,字,和字节个数
    
    head - 输出文件第一部分
    
    tail - 输出文件最后一部分
    
    tee - 从标准输入读取数据,并同时写到标准输出和文件
  • 相关阅读:
    重构FourlegLayers控件
    XNA 没有经过Content Pipeline对内容做Alpha预处理解决办法
    山寨DNF
    XNA中 SpriteSortMode 与 BlendState 《摘自王磊文章》
    HDU1060 Leftmost Digit
    HDU1095 A hard puzzle
    magento安装心得
    关于小米手机网站抢购的一点技术分析
    MVC3和MVC4内置Razor引擎的差异
    查看进程
  • 原文地址:https://www.cnblogs.com/allen2333/p/8875195.html
Copyright © 2011-2022 走看看