cat(是 concatenate 的縮寫)命令
用于連接文件并打印到標準輸出設(shè)備上
詳細說明:cat 命令的功能是將文件或標準輸入組合輸出到標準輸出虏缸。這個命令常用來顯示文件內(nèi)容,或者將幾個文件連接起來顯示,或者從標準輸入讀取內(nèi)容并顯示,它常與重定向符號配合使用鸵膏。
用法及參數(shù)如下:
$cat --help
Usage: cat [OPTION]... [FILE]...
Concatenate FILE(s), or standard input, to standard output.
-A, --show-all equivalent to -vET #等價于 -vET
-b, --number-nonblank number nonempty output lines, overrides -n #和 -n 相似钦勘,只不過對于空白行不編號
-e equivalent to -vE #等價于"-vE"選項
-E, --show-ends display $ at end of each line #在每行結(jié)束處顯示 $
-n, --number number all output lines #由 1 開始對所有輸出的行數(shù)編號
-s, --squeeze-blank suppress repeated empty output lines #當遇到有連續(xù)兩行以上的空白行氧卧,就代換為一行的空白行
-t equivalent to -vT #等價于 -vET
-T, --show-tabs display TAB characters as ^I #將 TAB 字符顯示為 ^I
-u (ignored) #被忽略
-v, --show-nonprinting use ^ and M- notation, except for LFD and TAB #使用 ^ 和 M- 符號右莱,除了 LFD 和 TAB 之外
--help display this help and exit #展示幫助選項并退出
--version output version information and exit #輸出版本號信息并退出
With no FILE, or when FILE is -, read standard input.
Examples:
cat f - g Output f's contents, then standard input, then g's contents.
cat Copy standard input to standard output.
cat命令的三大功能:
1、一次顯示整個文件內(nèi)容
$cat filename
2档插、從鍵盤創(chuàng)建一個新文件慢蜓,不能更改已有文件
$cat > filename
3、將幾個文件合并成一個文件
$cat file1 file2 > mergefile
$zcat test1.fastq.gz test2.fastq.gz …… > total.fastq.gz
#直接cat再合并也可以阀捅,最后的結(jié)果和zcat一樣
$cat test1.fastq.gz test2.fastq.gz …… > total.fastq.gz
tac 是將 cat 反寫過來胀瞪,所以它的功能就跟 cat 相反针余,cat 是由第一行到最后一行連續(xù)顯示在屏幕上饲鄙,而 tac 則是由最后一行到第一行反向在屏幕上顯示出來
用法及參數(shù):
Usage: tac [OPTION]... [FILE]...
Write each FILE to standard output, last line first.
With no FILE, or when FILE is -, read standard input.
Mandatory arguments to long options are mandatory for short options too.
-b, --before attach the separator before instead of after #將分隔符安裝在之前而不是之后
-r, --regex interpret the separator as a regular expression #將分隔符解釋為正則表達式
-s, --separator=STRING use STRING as the separator instead of newline #使用STRING作為分隔符而不是換行符
--help display this help and exit #展示幫助選項并退出
--version output version information and exit #輸出版本號并退出
#zcat查看壓縮文件最后一行是否有換行符
#gz壓縮文件:輸出為1表示有換行,輸出為0表示無換行
zcat DRR138629_1.fastq.gz | tail -1 | wc -l
#僅僅是fastq文件:輸出為1表示有換行圆雁,輸出為0表示無換行
tail -1 DRR138629_1.fastq | wc -l
#提取fastq.gz文件中一個單元的第一二行
zcat DRR138627_41_total.fastq.gz | awk '{if(NR%4 == 1){print ">" substr($0, 2)}}{if(NR%4 == 2){print}}' > DRR138627_41_total.fasta
>NS500460:4:H13G4BGXX:1:11102:10658:8619 1:N:0:3
CCTTAATCAGGATCAATGCCTTTTCGGGCTTATCACAGATCACTGTGGCAATCTCAGCTTTGTTGATAATGTATTT
>NS500460:4:H13G4BGXX:1:11102:3954:8619 1:N:0:3
GTCCACATTCAGATTTTCCCAGGAAGAAACGCCTCGTGTGCCAGTCCAGATGCTGATTGAAAAGCCAGCCCCCAGG
總之忍级,一句話:查看gz文件用zcat test.fastq.gz | head -20,查看fastq文件用head伪朽。
#返回系統(tǒng)語言
echo $LANG
#設(shè)置系統(tǒng)語言為中文
LANG=zh_CN.UTF-8
#設(shè)置系統(tǒng)語言為英文
LANG=en_US.UTF-8
#查看系統(tǒng)語言
date