【发布时间】:2018-11-30 14:04:12
【问题描述】:
我有一个包含数据的 CSV
$cat content.csv
MD5 : 1d4571a01abfbfe1a653a86109c5587f , Detection : Unknown.Trojan.Generickd , Level : 5, Factor : 5, VT Positives 13
MD5 : 03f44b4a8eb4a3b88d8307452eb5b556 , Detection : Document-Word.Exploit.CVE-2012-0013 , Level : 5, Factor : 5, VT Positives 0
MD5 : 58e9db1ec0fa687ee7c1510504a087c8 , Detection : Document-Powerpoint.Trojan.Vba agent , Level : 5, Factor : 5, VT Positives 4
MD5 : 1d025e72e82199d1524a9249073b338d , Detection : Document-Powerpoint.Trojan.Valyria , Level : 5, Factor : 5, VT Positives 1
MD5 : b3039d8f5d616c77297f0da3d5b444ea , Detection : Win32.Trojan.Dynamer , Level : 5, Factor : 5, VT Positives 36
MD5 : 833ab86e5f3d915dba7eea7e79a9c11e , Detection : Win32.Virus.Sality , Level : 5, Factor : 5, VT Positives 42
MD5 : 4f08e1c23ba22eb3bb1e7a7f2418f187 , Detection : Document-Powerpoint.Trojan.Valyria , Level : 5, Factor : 5, VT Positives 1
MD5 : bed56264438a7da43a98073497c74f73 , Detection : DOS.Virus.Arcv , Level : 5, Factor : 5, VT Positives 31
我想基于分隔符"," 在第 5 个字段(VT 正数)上再次使用所有字段(1 到 5)进行数字 sort
我试过了
$ cut -d"," -f 1,2,3,4,5 kiran | sort -k 5
MD5 : bed56264438a7da43a98073497c74f73 , Detection : DOS.Virus.Arcv , Level : 5, Factor : 5, VT Positives 31
MD5 : 1d025e72e82199d1524a9249073b338d , Detection : Document-Powerpoint.Trojan.Valyria , Level : 5, Factor : 5, VT Positives 1
MD5 : 4f08e1c23ba22eb3bb1e7a7f2418f187 , Detection : Document-Powerpoint.Trojan.Valyria , Level : 5, Factor : 5, VT Positives 1
MD5 : 58e9db1ec0fa687ee7c1510504a087c8 , Detection : Document-Powerpoint.Trojan.Vba agent , Level : 5, Factor : 5, VT Positives 4
MD5 : 03f44b4a8eb4a3b88d8307452eb5b556 , Detection : Document-Word.Exploit.CVE-2012-0013 , Level : 5, Factor : 5, VT Positives 0
MD5 : 1d4571a01abfbfe1a653a86109c5587f , Detection : Unknown.Trojan.Generickd , Level : 5, Factor : 5, VT Positives 13
MD5 : b3039d8f5d616c77297f0da3d5b444ea , Detection : Win32.Trojan.Dynamer , Level : 5, Factor : 5, VT Positives 36
MD5 : 833ab86e5f3d915dba7eea7e79a9c11e , Detection : Win32.Virus.Sality , Level : 5, Factor : 5, VT Positives 42
sort -t$"," -k 5 -n kiran
MD5 : 03f44b4a8eb4a3b88d8307452eb5b556 , Detection : Document-Word.Exploit.CVE-2012-0013 , Level : 5, Factor : 5, VT Positives 0
MD5 : 1d025e72e82199d1524a9249073b338d , Detection : Document-Powerpoint.Trojan.Valyria , Level : 5, Factor : 5, VT Positives 1
MD5 : 1d4571a01abfbfe1a653a86109c5587f , Detection : Unknown.Trojan.Generickd , Level : 5, Factor : 5, VT Positives 13
MD5 : 4f08e1c23ba22eb3bb1e7a7f2418f187 , Detection : Document-Powerpoint.Trojan.Valyria , Level : 5, Factor : 5, VT Positives 1
MD5 : 58e9db1ec0fa687ee7c1510504a087c8 , Detection : Document-Powerpoint.Trojan.Vba agent , Level : 5, Factor : 5, VT Positives 4
MD5 : 833ab86e5f3d915dba7eea7e79a9c11e , Detection : Win32.Virus.Sality , Level : 5, Factor : 5, VT Positives 42
MD5 : b3039d8f5d616c77297f0da3d5b444ea , Detection : Win32.Trojan.Dynamer , Level : 5, Factor : 5, VT Positives 36
MD5 : bed56264438a7da43a98073497c74f73 , Detection : DOS.Virus.Arcv , Level : 5, Factor : 5, VT Positives 31
尝试了多种组合,它没有按预期工作。请问有什么建议吗?
【问题讨论】:
标签: bash shell sorting awk cut