我有這樣的bash腳本:bash腳本排序輸入文件之前,管道到while循環
while IFS='"' read -r a ip c
do
echo "ip: $ip"
whois "$ip" | grep netname
done < <(head -10 file.log)
我怎麼能(與sort -n -r
如)排序file.log
文件則採用前十行之前,並移交給while循環?
我有這樣的bash腳本:bash腳本排序輸入文件之前,管道到while循環
while IFS='"' read -r a ip c
do
echo "ip: $ip"
whois "$ip" | grep netname
done < <(head -10 file.log)
我怎麼能(與sort -n -r
如)排序file.log
文件則採用前十行之前,並移交給while循環?
如果你想排序後得到的前10線,採用head
只是sort
之前:
while IFS='"' read -r a ip c
do
echo "ip: $ip"
whois "$ip" | grep netname
done < <(sort file.log | head -10)
^^^^^^^^^^^^^^^
應用您所需要的sort
標誌,當然。
'head -10 file.log | sort -nr' –
'sort -nr file.log |頭-10' – cmbuckley