[root@localhost ~]# echo "1 2 3 4 5" | awk '{for(i=1;i<3;i++)$i="";print}' 3 4 5
[root@localhost ~]#echo "1 2 3 4 5" | awk '{$1=$2="";print}' 3 4 5
[root@jizhong Fri Aug 18 14:05:26 ~]# echo "1 2 3 4 5" | cut -d" " -f3- 3 4 5
[root@jizhong Fri Aug 18 14:06:47 ~]# echo "1 2 3 4 5" | awk '{$1=$2=""}1' 3 4 5
文本內容格式以下 MD_Q9_G1_F MD_Q9_G1_Ua MD_Q9_G1_Ub MD_Q9_G1_Uc MD_Q9_G1_Uab MD_Q9_G1_Ubc MD_Q9_G1_Uca MD_Q9_G1_Ia MD_Q9_G1_Ib MD_Q9_G1_Ic MD_Q9_G1_Pa MD_Q9_G1_Pb MD_Q9_G1_Pc MD_Q9_G1_Psum MD_Q9_G1_Qa MD_Q9_G1_Qb MD_Q9_G1_Qc MD_Q9_G1_Qsum MD_Q9_G1_Sa MD_Q9_G1_Sb MD_Q9_G1_Sc MD_Q9_G1_Ssum MD_Q9_G1_PFa MD_Q9_G1_PFb MD_Q9_G1_PFc MD_Q9_G1_PF
awk '{ORS=NR%50?",":RS}1'
可是,paste只有將多行合併爲一行,但並無分割的功能 要是有,但願大神指點
awk 'NR%50{printf $0",";next}1' 當NR取餘非零時,執行{printf $0",";next},並跳過1(1表示print) 當NR取餘爲零時,執行1({print $0})print默認換行
awk '{OFS=",";ORS=NR%50?OFS:RS}1' 知足條件時,輸出爲OFS(即,) 不然使用RS爲輸出符
pattern省略或爲1,等價於 /.*/shell
action省略,等價於 { print $0 }code
awk將變量傳給shell能夠用eval, 如 eval $(awk 'BEGIN{print "a=ggg b=3"}')則shell變量$a就是ggg,shell變量$b就是3字符串