zoukankan      html  css  js  c++  java
  • Linux Command Line 备忘

    1. 如果要删除目录,

    rmdir or rm -d 或许可以删除空目录,但是只有
    rm -R 可以把目录以及其内容连带删除!

    2. 查看文件大小:

    ls -l --block-size=G 还可以换成MB
    #or 
    ls -lh

    3. mac中使用sudo user:

    sudo -s
    然后输入你的用户密码(不是master code)即可!

    4. 截取部分文件

    截取行: head -100 file.txt > top_100_row.txt 同理可用tail截取  还可使用grep进行行的选择
    
    截取列: cut -f1-10 -d',' file.txt > top_10_column.txt

     5. 查找文件中是否含有某字符串

    #查找目录下的所有文件中是否含有某个字符串 
    find .|xargs grep -ri "IBM" 
    #查找目录下的所有文件中是否含有某个字符串,并且只打印出文件名 
    find .|xargs grep -ri "IBM" -l 
    #or 
    find ./ -name "IBM"
    #Ref:http://blog.sina.com.cn/s/blog_691a84f301015khx.html

    6. Export path

    export PATH=/Volumes/Macintosh_HD_2/Programs/samtools-0.1.19/misc/:$PATH
    #you can now type directly on the terminal "samtools"

     7. comm 命令

    #找出两个文件不同的地方:
    comm -23 <(sort a) <(sort b)
    #注意这里的“<“。这个符号是”using a file as standard input"
    #i.e. cat xyz.txt 和 cat < xyz.txt 效果是一样的

    8. sed command

    #to delete the 3rd line of a file
    sed '3d' fileName.txt
    #to select several lines of a file
    sed -n '320123,320150'p filename

    9. less command

    less text.txt 
    #then, just type 
    450g
    #you can find the 450th line
  • 相关阅读:
    .net 面试题之 输出 空 三角型
    js 里 用XML httpRequest 调用 Web Service
    C# 设计模式之 单例模式
    C#TreeView 实现无线级别分类
    asp.net Session的原理
    .Net 面试题之 查询两个时间差
    暑 假 队 测 Round #2
    两个排序算法的扩展应用
    暑 假 队 测 Round #1
    二维单调队列或st表
  • 原文地址:https://www.cnblogs.com/foreverycc/p/3242311.html
Copyright © 2011-2022 走看看