打印與得分最高的線我有一個CSV這樣解析CSV使用bash shell的
Parameter Values,Count,% of Results
" david;[email protected];10300 "," 15 "," 50.0% "
" david;[email protected];12300 "," 15 "," 50.0% "
" davidk;[email protected];32300 "," 15 "," 50.0% "
" joe;[email protected];9200 "," 15 "," 50.0% "
" john;[email protected];1500 "," 15 "," 50.0% "
我想要得到的是具有最高數值的線,在這種情況下,32300
我已經在做這個嘗試,但它使用幾個命令
export max=$(awk -F, '{split($1,a,";"); print a[3] }' contestEntryTest.csv | tr -d ' "' | sort -nr | head -n 1) ; grep $max contestEntryTest.csv
我怎樣才能做到上面較少的命令或一個命令,如何將一個更有經驗的程序員的bash做上述問題,只是利爾寧經驗。 乾杯!
哇,這是簡單的,感謝您的回答。我只是想知道哪個具有最好的性能或awk,或者可以忽略不計。 – tsukimi 2012-03-14 02:51:53
@tsukimi我認爲性能基於你的數據的大小/內容,排序將處理所有條目,但awk進程腳本更加複雜,所以不容易說誰更快。 – PasteBT 2012-03-14 03:17:42