亚洲av成人无遮挡网站在线观看,少妇性bbb搡bbb爽爽爽,亚洲av日韩精品久久久久久,兔费看少妇性l交大片免费,无码少妇一区二区三区

  免費注冊 查看新帖 |

Chinaunix

  平臺 論壇 博客 文庫
12下一頁
最近訪問板塊 發(fā)新帖
查看: 5722 | 回復(fù): 11
打印 上一主題 下一主題

[文本處理] 如何按照某個字段排序 [復(fù)制鏈接]

論壇徽章:
0
跳轉(zhuǎn)到指定樓層
1 [收藏(0)] [報告]
發(fā)表于 2014-02-24 15:43 |只看該作者 |倒序瀏覽
<httpSample t="332" lt="332" ts="1393225455257" s="true" lb="10" rc="200" rm="OK" tn="/hotel 1-34" dt="text" by="252"/>
<httpSample t="354" lt="354" ts="1393225455324" s="true" lb="10" rc="200" rm="OK" tn="/hotel 1-135" dt="text" by="252"/>
<httpSample t="452" lt="452" ts="1393225455295" s="true" lb="10" rc="200" rm="OK" tn="/hotel 1-105" dt="text" by="252"/>
<httpSample t="511" lt="511" ts="1393225455271" s="true" lb="10" rc="200" rm="OK" tn="/hotel 1-29" dt="text" by="252"/>
<httpSample t="515" lt="515" ts="1393225455269" s="true" lb="10" rc="200" rm="OK" tn="/hotel 1-82" dt="text" by="252"/>
<httpSample t="568" lt="568" ts="1393225455269" s="true" lb="10" rc="200" rm="OK" tn="/hotel 1-83" dt="text" by="252"/>
<httpSample t="586" lt="586" ts="1393225455257" s="true" lb="10" rc="200" rm="OK" tn="/hotel 1-44" dt="text" by="252"/>
<httpSample t="667" lt="667" ts="1393225455252" s="true" lb="10" rc="200" rm="OK" tn="/hotel 1-55" dt="text" by="252"/>
<httpSample t="861" lt="860" ts="1393225455257" s="true" lb="10" rc="200" rm="OK" tn="/hotel 1-46" dt="text" by="10421"/>
<httpSample t="895" lt="893" ts="1393225455254" s="true" lb="10" rc="200" rm="OK" tn="/hotel 1-60" dt="text" by="10643"/>
<httpSample t="896" lt="894" ts="1393225455264" s="true" lb="10" rc="200" rm="OK" tn="/hotel 1-72" dt="text" by="10378"/>
<httpSample t="937" lt="937" ts="1393225455267" s="true" lb="10" rc="200" rm="OK" tn="/hotel 1-31" dt="text" by="12981"/>

這樣的一個文件,希望 按照 t  這個field 進(jìn)行排序。

應(yīng)該怎么整?

謝謝

論壇徽章:
145
技術(shù)圖書徽章
日期:2013-10-01 15:32:13戌狗
日期:2013-10-25 13:31:35金牛座
日期:2013-11-04 16:22:07子鼠
日期:2013-11-18 18:48:57白羊座
日期:2013-11-29 10:09:11獅子座
日期:2013-12-12 09:57:42白羊座
日期:2013-12-24 16:24:46辰龍
日期:2014-01-08 15:26:12技術(shù)圖書徽章
日期:2014-01-17 13:24:40巳蛇
日期:2014-02-18 14:32:59未羊
日期:2014-02-20 14:12:13白羊座
日期:2014-02-26 12:06:59
2 [報告]
發(fā)表于 2014-02-24 15:52 |只看該作者
本帖最后由 jason680 于 2014-02-24 16:04 編輯

回復(fù) 1# sulaimani_yu

try this way
Note: your file is already sorted

sort -t'"' -k2,2n FILE
   
Note: mark it to get command

論壇徽章:
33
榮譽會員
日期:2011-11-23 16:44:17天秤座
日期:2014-08-26 16:18:20天秤座
日期:2014-08-29 10:12:18丑牛
日期:2014-08-29 16:06:45丑牛
日期:2014-09-03 10:28:58射手座
日期:2014-09-03 16:01:17寅虎
日期:2014-09-11 14:24:21天蝎座
日期:2014-09-17 08:33:55IT運維版塊每日發(fā)帖之星
日期:2016-04-17 06:23:27操作系統(tǒng)版塊每日發(fā)帖之星
日期:2016-04-18 06:20:00IT運維版塊每日發(fā)帖之星
日期:2016-04-24 06:20:0015-16賽季CBA聯(lián)賽之天津
日期:2016-05-06 12:46:59
3 [報告]
發(fā)表于 2014-02-24 15:52 |只看該作者
開房記錄 ?

論壇徽章:
0
4 [報告]
發(fā)表于 2014-02-24 16:00 |只看該作者
sort不出來啊

論壇徽章:
36
摩羯座
日期:2013-09-23 16:37:312015年亞洲杯之沙特阿拉伯
日期:2015-04-14 09:10:172015亞冠之柏太陽神
日期:2015-06-25 08:48:212015亞冠之武里南聯(lián)
日期:2015-07-28 09:01:082015亞冠之萊赫維亞
日期:2015-07-28 15:44:172015亞冠之柏斯波利斯
日期:2015-09-06 14:08:52白銀圣斗士
日期:2015-11-25 17:06:2815-16賽季CBA聯(lián)賽之吉林
日期:2015-12-09 16:59:072016猴年福章徽章
日期:2016-02-18 15:30:3415-16賽季CBA聯(lián)賽之遼寧
日期:2016-04-14 09:29:04luobin
日期:2016-06-17 17:46:3615-16賽季CBA聯(lián)賽之天津
日期:2016-08-16 14:11:01
5 [報告]
發(fā)表于 2014-02-24 16:06 |只看該作者
  1. sort -nk 2
復(fù)制代碼
回復(fù) 4# sulaimani_yu


   

論壇徽章:
0
6 [報告]
發(fā)表于 2014-02-24 16:16 |只看該作者
回復(fù) 5# LikeLx

謝謝啊,

不過好像結(jié)果不太對。我希望按照數(shù)字大小的順序排列。您這個是按照字符順序排列了

<httpSample t="1999" lt="1999" ts="1393225460663" s="true" lb="10" rc="200" rm="OK" tn="/hotel 1-1626" dt="text" by="210"/>
<httpSample t="1999" lt="1999" ts="1393225461365" s="true" lb="10" rc="200" rm="OK" tn="/hotel 1-1703" dt="text" by="252"/>
<httpSample t="199" lt="195" ts="1393225461365" s="true" lb="10" rc="200" rm="OK" tn="/hotel 1-1459" dt="text" by="13031"/>
<httpSample t="199" lt="196" ts="1393225461627" s="true" lb="10" rc="200" rm="OK" tn="/hotel 1-2074" dt="text" by="13031"/>
<httpSample t="199" lt="198" ts="1393225457151" s="true" lb="10" rc="200" rm="OK" tn="/hotel 1-366" dt="text" by="10722"/>
<httpSample t="2000" lt="2000" ts="1393225458441" s="true" lb="10" rc="200" rm="OK" tn="/hotel 1-431" dt="text" by="210"/>

1999排到199前面去了
   

論壇徽章:
33
榮譽會員
日期:2011-11-23 16:44:17天秤座
日期:2014-08-26 16:18:20天秤座
日期:2014-08-29 10:12:18丑牛
日期:2014-08-29 16:06:45丑牛
日期:2014-09-03 10:28:58射手座
日期:2014-09-03 16:01:17寅虎
日期:2014-09-11 14:24:21天蝎座
日期:2014-09-17 08:33:55IT運維版塊每日發(fā)帖之星
日期:2016-04-17 06:23:27操作系統(tǒng)版塊每日發(fā)帖之星
日期:2016-04-18 06:20:00IT運維版塊每日發(fā)帖之星
日期:2016-04-24 06:20:0015-16賽季CBA聯(lián)賽之天津
日期:2016-05-06 12:46:59
7 [報告]
發(fā)表于 2014-02-24 16:19 |只看該作者
sort -t '"' -nk2 urfile

論壇徽章:
32
處女座
日期:2013-11-20 23:41:20雙子座
日期:2014-06-11 17:20:43戌狗
日期:2014-06-16 11:05:00處女座
日期:2014-07-22 17:30:47獅子座
日期:2014-07-28 15:38:17金牛座
日期:2014-08-05 16:34:01亥豬
日期:2014-08-18 13:34:25白羊座
日期:2014-09-02 15:03:55金牛座
日期:2014-11-10 10:23:58處女座
日期:2014-12-02 09:17:52程序設(shè)計版塊每日發(fā)帖之星
日期:2015-06-16 22:20:002015亞冠之塔什干火車頭
日期:2015-06-20 23:28:22
8 [報告]
發(fā)表于 2014-02-24 17:18 |只看該作者
本帖最后由 yestreenstars 于 2014-02-25 16:52 編輯
  1. $ awk '{a[gensub(/.*\st="([0-9]+)".*/,"\\1",1)]=$0}END{for(i=0;i++<asort(a);)print a[i]}' i
  2. <httpSample t="332" lt="332" ts="1393225455257" s="true" lb="10" rc="200" rm="OK" tn="/hotel 1-34" dt="text" by="252"/>
  3. <httpSample t="354" lt="354" ts="1393225455324" s="true" lb="10" rc="200" rm="OK" tn="/hotel 1-135" dt="text" by="252"/>
  4. <httpSample t="452" lt="452" ts="1393225455295" s="true" lb="10" rc="200" rm="OK" tn="/hotel 1-105" dt="text" by="252"/>
  5. <httpSample t="511" lt="511" ts="1393225455271" s="true" lb="10" rc="200" rm="OK" tn="/hotel 1-29" dt="text" by="252"/>
  6. <httpSample t="515" lt="515" ts="1393225455269" s="true" lb="10" rc="200" rm="OK" tn="/hotel 1-82" dt="text" by="252"/>
  7. <httpSample t="568" lt="568" ts="1393225455269" s="true" lb="10" rc="200" rm="OK" tn="/hotel 1-83" dt="text" by="252"/>
  8. <httpSample t="586" lt="586" ts="1393225455257" s="true" lb="10" rc="200" rm="OK" tn="/hotel 1-44" dt="text" by="252"/>
  9. <httpSample t="667" lt="667" ts="1393225455252" s="true" lb="10" rc="200" rm="OK" tn="/hotel 1-55" dt="text" by="252"/>
  10. <httpSample t="861" lt="860" ts="1393225455257" s="true" lb="10" rc="200" rm="OK" tn="/hotel 1-46" dt="text" by="10421"/>
  11. <httpSample t="895" lt="893" ts="1393225455254" s="true" lb="10" rc="200" rm="OK" tn="/hotel 1-60" dt="text" by="10643"/>
  12. <httpSample t="896" lt="894" ts="1393225455264" s="true" lb="10" rc="200" rm="OK" tn="/hotel 1-72" dt="text" by="10378"/>
  13. <httpSample t="937" lt="937" ts="1393225455267" s="true" lb="10" rc="200" rm="OK" tn="/hotel 1-31" dt="text" by="12981"/>
復(fù)制代碼

論壇徽章:
36
摩羯座
日期:2013-09-23 16:37:312015年亞洲杯之沙特阿拉伯
日期:2015-04-14 09:10:172015亞冠之柏太陽神
日期:2015-06-25 08:48:212015亞冠之武里南聯(lián)
日期:2015-07-28 09:01:082015亞冠之萊赫維亞
日期:2015-07-28 15:44:172015亞冠之柏斯波利斯
日期:2015-09-06 14:08:52白銀圣斗士
日期:2015-11-25 17:06:2815-16賽季CBA聯(lián)賽之吉林
日期:2015-12-09 16:59:072016猴年福章徽章
日期:2016-02-18 15:30:3415-16賽季CBA聯(lián)賽之遼寧
日期:2016-04-14 09:29:04luobin
日期:2016-06-17 17:46:3615-16賽季CBA聯(lián)賽之天津
日期:2016-08-16 14:11:01
9 [報告]
發(fā)表于 2014-02-24 22:11 |只看該作者
  1. [root@dbserver ~]# cat a.txt
  2. <httpSample t="332" lt="332" ts="1393225455257" s="true" lb="10" rc="200" rm="OK" tn="/hotel 1-34" dt="text" by="252"/>
  3. <httpSample t="354" lt="354" ts="1393225455324" s="true" lb="10" rc="200" rm="OK" tn="/hotel 1-135" dt="text" by="252"/>
  4. <httpSample t="452" lt="452" ts="1393225455295" s="true" lb="10" rc="200" rm="OK" tn="/hotel 1-105" dt="text" by="252"/>
  5. <httpSample t="511" lt="511" ts="1393225455271" s="true" lb="10" rc="200" rm="OK" tn="/hotel 1-29" dt="text" by="252"/>
  6. <httpSample t="123" lt="515" ts="1393225455269" s="true" lb="10" rc="200" rm="OK" tn="/hotel 1-82" dt="text" by="252"/>
  7. <httpSample t="568" lt="568" ts="1393225455269" s="true" lb="10" rc="200" rm="OK" tn="/hotel 1-83" dt="text" by="252"/>
  8. <httpSample t="586" lt="586" ts="1393225455257" s="true" lb="10" rc="200" rm="OK" tn="/hotel 1-44" dt="text" by="252"/>
  9. <httpSample t="667" lt="667" ts="1393225455252" s="true" lb="10" rc="200" rm="OK" tn="/hotel 1-55" dt="text" by="252"/>
  10. <httpSample t="861" lt="860" ts="1393225455257" s="true" lb="10" rc="200" rm="OK" tn="/hotel 1-46" dt="text" by="10421"/>
  11. <httpSample t="895" lt="893" ts="1393225455254" s="true" lb="10" rc="200" rm="OK" tn="/hotel 1-60" dt="text" by="10643"/>
  12. <httpSample t="896" lt="894" ts="1393225455264" s="true" lb="10" rc="200" rm="OK" tn="/hotel 1-72" dt="text" by="10378"/>
  13. <httpSample t="937" lt="937" ts="1393225455267" s="true" lb="10" rc="200" rm="OK" tn="/hotel 1-31" dt="text" by="12981"/>
  14. [root@dbserver ~]# sort -nk2

  15. [root@dbserver ~]# sort -nk2 a.txt
  16. <httpSample t="123" lt="515" ts="1393225455269" s="true" lb="10" rc="200" rm="OK" tn="/hotel 1-82" dt="text" by="252"/>
  17. <httpSample t="332" lt="332" ts="1393225455257" s="true" lb="10" rc="200" rm="OK" tn="/hotel 1-34" dt="text" by="252"/>
  18. <httpSample t="354" lt="354" ts="1393225455324" s="true" lb="10" rc="200" rm="OK" tn="/hotel 1-135" dt="text" by="252"/>
  19. <httpSample t="452" lt="452" ts="1393225455295" s="true" lb="10" rc="200" rm="OK" tn="/hotel 1-105" dt="text" by="252"/>
  20. <httpSample t="511" lt="511" ts="1393225455271" s="true" lb="10" rc="200" rm="OK" tn="/hotel 1-29" dt="text" by="252"/>
  21. <httpSample t="568" lt="568" ts="1393225455269" s="true" lb="10" rc="200" rm="OK" tn="/hotel 1-83" dt="text" by="252"/>
  22. <httpSample t="586" lt="586" ts="1393225455257" s="true" lb="10" rc="200" rm="OK" tn="/hotel 1-44" dt="text" by="252"/>
  23. <httpSample t="667" lt="667" ts="1393225455252" s="true" lb="10" rc="200" rm="OK" tn="/hotel 1-55" dt="text" by="252"/>
  24. <httpSample t="861" lt="860" ts="1393225455257" s="true" lb="10" rc="200" rm="OK" tn="/hotel 1-46" dt="text" by="10421"/>
  25. <httpSample t="895" lt="893" ts="1393225455254" s="true" lb="10" rc="200" rm="OK" tn="/hotel 1-60" dt="text" by="10643"/>
  26. <httpSample t="896" lt="894" ts="1393225455264" s="true" lb="10" rc="200" rm="OK" tn="/hotel 1-72" dt="text" by="10378"/>
  27. <httpSample t="937" lt="937" ts="1393225455267" s="true" lb="10" rc="200" rm="OK" tn="/hotel 1-31" dt="text" by="12981"/>
  28. [root@dbserver ~]#
復(fù)制代碼
回復(fù) 6# sulaimani_yu

不是這個意思嗎?
   

論壇徽章:
29
程序設(shè)計版塊每日發(fā)帖之星
日期:2016-02-29 06:20:0015-16賽季CBA聯(lián)賽之天津
日期:2016-08-10 10:33:1115-16賽季CBA聯(lián)賽之深圳
日期:2016-08-17 15:07:2015-16賽季CBA聯(lián)賽之佛山
日期:2016-11-07 11:33:5015-16賽季CBA聯(lián)賽之廣夏
日期:2016-11-15 09:13:31CU十四周年紀(jì)念徽章
日期:2016-11-24 14:12:25極客徽章
日期:2016-12-07 14:03:4015-16賽季CBA聯(lián)賽之深圳
日期:2016-12-07 17:15:2715-16賽季CBA聯(lián)賽之北京
日期:2016-12-22 09:30:0115-16賽季CBA聯(lián)賽之深圳
日期:2016-12-22 10:49:2115-16賽季CBA聯(lián)賽之山西
日期:2017-02-10 09:05:3215-16賽季CBA聯(lián)賽之同曦
日期:2017-02-27 14:19:08
10 [報告]
發(fā)表于 2014-02-24 22:35 |只看該作者
sort -t \" -k2,2n
您需要登錄后才可以回帖 登錄 | 注冊

本版積分規(guī)則 發(fā)表回復(fù)

  

北京盛拓優(yōu)訊信息技術(shù)有限公司. 版權(quán)所有 京ICP備16024965號-6 北京市公安局海淀分局網(wǎng)監(jiān)中心備案編號:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年舉報專區(qū)
中國互聯(lián)網(wǎng)協(xié)會會員  聯(lián)系我們:huangweiwei@itpub.net
感謝所有關(guān)心和支持過ChinaUnix的朋友們 轉(zhuǎn)載本站內(nèi)容請注明原作者名及出處

清除 Cookies - ChinaUnix - Archiver - WAP - TOP