linux命令

WC

wc:word count 統計character,newline,

-l:統計行數

-c:統計字節數

-m:字符數

-w:字數

-L:文件最長行的字符數

無參數:行數,字數,字符數

ls | wc -l//To count all files and folders present in directory
wc -n | cut c1//Display number of word count only of a file

cut

取文件每行的某個部分
cutting out the sections from each line of files

-b:取某些字節 可有以下範圍

n n- -n n-m
某個字節 從n到行結束 第一個到n 第n到m個

-c:取某些列

-f:取某些域,由delimiter區分,

-d:設置delimiter

–complement:互補

–output-delimiter:設置輸出的delimiter

cut -b 1- state.txt
cut -c -5 state.txt
 cut -f 1 state.txt
cut -d " " -f 1-4 state.txt
cut --complement -c 5 state.txt
cut -d " " -f 1,2 state.txt --output-delimiter='%'
cat state.txt | cut -d ' ' -f 1 | sort -r
cat state.txt | head -n 3 | cut -d ' ' -f 1 > list.txt

head

讀文件的頂部,默認是10行

-n :多少行

-c:多少個字節

-q:不輸出文件名字,用於多個文件

 head -n 5 state.txt
 head -c 6 state.txt
 head -q  state.txt capital.txt

SORT

-o 輸出到文件

-r 反向排序

-n數字排序

-nr:數字反序

-k:按照某列排序

-c:判斷是否排序

-u:去除重複的

-M:按月排序

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章