• 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
  • 相关阅读:
    Eclipse正确导入第三方project
    面试的基础_01字符串反向操作
    一个简单的实现了智能虚拟女友—图灵机器人
    Notepad++去除代码行号的几种方法
    fastjson将bean转成字符串时首字母变小写问题
    2015第34周二能收发邮件但不能打开网页解决方法
    2015第34周一
    2015第33周日
    2015第33周六
    构建自己的顾问团
  • 原文地址:https://www.cnblogs.com/foreverycc/p/3242311.html
Copyright © 2020-2023  润新知