您好,登錄后才能下訂單哦!
今天小編給大家分享一下linux怎么隨機(jī)抽取txt文件的行到新文件的相關(guān)知識(shí)點(diǎn),內(nèi)容詳細(xì),邏輯清晰,相信大部分人都還太了解這方面的知識(shí),所以分享這篇文章給大家參考一下,希望大家閱讀完這篇文章后有所收獲,下面我們一起來了解一下吧。
shuf 隨機(jī)抽取txt文件的行到新文件
如隨機(jī)選取train.txt中的200行保存在新文件 test.txt中
shuf train.txt -n 200 -o test.txt
查看 shuf 命令幫助 “shuf --help”
用法: shuf [選項(xiàng)]... [文件] 或者: shuf -e [選項(xiàng)]... [參數(shù)]... 或者: shuf -i LO-HI [選項(xiàng)]... Write a random permutation of the input lines to standard output. 如果沒有指定文件,或者文件為"-",則從標(biāo)準(zhǔn)輸入讀取。 必選參數(shù)對長短選項(xiàng)同時(shí)適用。 -e, --echo treat each ARG as an input line -i, --input-range=LO-HI treat each number LO through HI as an input line -n, --head-count=COUNT output at most COUNT lines -o, --output=FILE write result to FILE instead of standard output --random-source=FILE get random bytes from FILE -r, --repeat output lines can be repeated -z, --zero-terminated line delimiter is NUL, not newline --help顯示此幫助信息并退出
以上就是“l(fā)inux怎么隨機(jī)抽取txt文件的行到新文件”這篇文章的所有內(nèi)容,感謝各位的閱讀!相信大家閱讀完這篇文章都有很大的收獲,小編每天都會(huì)為大家更新不同的知識(shí),如果還想學(xué)習(xí)更多的知識(shí),請關(guān)注億速云行業(yè)資訊頻道。
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。