YXF-biostar 基本命令

Example in this note: home/yxf/edu/lecture

The Unix bootcamp

  1. ls: list of files and directories in home directories
  2. pwd: Which directory you are working at
  3. mkdir: make new directory
    mkdir edu
  4. cd: change directory A to directory B.
    cd edu----change current directory to edu directory
  5. Back to home: cd / (cd /, cd ~ is same)
    cd home
    cd yxf
    or: cd /home/yxf
  6. cd .. : Navigate upward directory
    cd edu
    pwd: /home/yxf/edu
    cd ..
    pwd: /home/yxf
  7. Absolute path: No /
    Relative path:
  8. manual command: man ls
    man cd
    man man
  9. rm: remove directories
    rm ~/edu/lecture/
    rmdir data
    cd ..
    rmdir lecture
  10. touch: creat new empty file
    cd edu
    touch heaven.txt
    touch earth .txt
    ls
  11. mv(1): move file
    mkdir temp
    mv heaven.txt temp
    mv earth.txt temp
    ls temp
  12. mv(2): remame file (another function)
    tough rags
    ls
    mv rags temp/riches
    ls temp
  13. mv(3): move directories
    mv temp temp2
    ls temp2
  14. rm: remove file
    cd templs
    rm -i earth.txt heaven.txt rags (Function of "i" command-line option is to ask for confirmation)
  15. cp: copy files
    touch file1
    cp file1 file2 ---in same directory
    ls
    touch ~/edu/file3
    cp ~edu/file3 ~/edu/lecture/
  16. echo: put text in a file and view it
    ecoh "call me king"
    call me king
    ecoh "call me king" > oening_line.txt
    ls
    more opening_line.txt-----view content of file
  17. cat: combine multiple files
    echo "the primroses were over." >> opening_line.txt
    cat opening_line.txt

Data analysis

  1. Download data online (file name is "SGD_features.tab")
    At first make a new directory (lec03) and then download data in new directory
  2. View data
    more SGD_features.README
  3. Open stream from data
    cat SGD_features.tab
  4. Check how many lines in the file
    cat SGD_features.tab | wc -l
    "cat SGD_features.tab | wc" or "wc -l SGD_features.tab" will check the number of lines, words and characters
  5. Search desired data:
    grep: which lines match a certain pattern
    cat SGD_features.tab | grep YAL060W ----Find information on gene YAL060W
    cat SGD_features.tab | grep YAL060W --color=always | head ----Highlight the matched pattern
  6. Search data without a given pattern
    cat SGD_features.tab | grep -v Dubious | wc -l ---- the number of lines which not contain "Dubious"
  7. Store result in a new file
    ">" character is redirection
    cat SGD_features.tab | grep YAL060W > match.tab
  8. How to select gene
    "cut" is used to select certain colimn of gene
    cat SGD_features.tab | cut -f 2 | head ----select data of column 2
    cat SGD_features.tab | cut -f 2 | grep ORF | wc -l ----how many ORF gene
    cat SGD_features.tab | cut -f 2,3,4 | grep ORF | head ----select multiple columns
  9. How many feature types are in this data
    Make a new file for this feature type(ORF): cat SGD_features.tab | cut -f 2 > types.txt
    ?sorting
    ?unique

Compressed files and directories

  1. Compressed format
    Single file : .gz, .bz, .bz2, .zip
    Multiple files: .tar.gz, .tar.bz2
  2. How to compress or uncompress a file
    data: AF086833.fa
    compress: gzip AF086833
    uncompress: gunzip AF086833.fa.gz
  3. How to compress or uncompress multiple files
    data: AF086833.fa, AF086833.gb
    Compress format: tar czfv archive-name list-of-files-that-go-into-the-archive
    czfv: creat a compressed file in verbose mode
    tar czfv sequences.tar.gz AF086833.fa AF086833.gb
    Or: tar czvf sequences.tar.gz AF086833.*
    Better way: mkdir sequences
    mv AF086833.* aequences/
    tar czvf sequences.tar.gz sequences/*

管道命令:就是多个命令联用,上一个命令的输出是下一个命令的输入。通俗来讲就是命令A的数据结果就是命令B的输入数据,两个命令之间以管道符“|”连接

你可能感兴趣的:(YXF-biostar 基本命令)