以下是给出的ls
输出:
-rw-r----- 1 ronald ronald 300488 2019-10-11 21:29 1570840157.M399816P376041.br472.hostgator.com.br,S=300488,W=304621:2,
-rw-r----- 1 ronald ronald 307582 2019-10-11 21:30 1570840228.M85932P379995.br472.hostgator.com.br,S=307582,W=311813:2,
-rw-r----- 1 ronald ronald 301166 2019-10-11 21:31 1570840312.M211863P379995.br472.hostgator.com.br,S=301166,W=305309:2,
-rw-r----- 1 ronald ronald 308153 2019-10-11 21:32 1570840376.M535629P379995.br472.hostgator.com.br,S=308153,W=312391:2,
-rw-r----- 1 ronald ronald 307387 2019-10-11 21:34 1570840441.M68421P382468.br472.hostgator.com.br,S=307387,W=311615:2,
-rw-r----- 1 ronald ronald 298927 2019-10-11 21:35 1570840530.M391347P385138.br472.hostgator.com.br,S=298927,W=303039:2,
-rw-r----- 1 ronald ronald 302107 2019-10-11 21:36 1570840597.M688174P387663.br472.hostgator.com.br,S=302107,W=306263:2,
-rw-r----- 1 ronald ronald 299284 2019-10-11 21:37 1570840657.M991954P387663.br472.hostgator.com.br,S=299284,W=303401:2,
-rw-r----- 1 ronald ronald 299941 2019-10-11 21:39 1570840743.M587693P390982.br472.hostgator.com.br,S=299941,W=304067:2,
-rw-r----- 1 ronald ronald 305586 2019-10-11 21:40 1570840805.M471644P390982.br472.hostgator.com.br,S=305586,W=309789:2,
-rw-r----- 1 ronald ronald 302585 2019-10-11 21:41 1570840869.M734632P390982.br472.hostgator.com.br,S=302585,W=306747:2,
-rw-r----- 1 ronald ronald 300967 2019-10-11 21:42 1570840929.M49892P396393.br472.hostgator.com.br,S=300967,W=305107:2,
-rw-r----- 1 ronald ronald 309171 2019-10-11 21:43 1570840996.M935135P396393.br472.hostgator.com.br,S=309171,W=313423:2,
-rw-r----- 1 ronald ronald 306032 2019-10-11 21:44 1570841063.M337072P398299.br472.hostgator.com.br,S=306032,W=310241:2,
-rw-r----- 1 ronald ronald 307273 2019-10-11 21:45 1570841123.M319021P399614.br472.hostgator.com.br,S=307273,W=311499:2,
-rw-r----- 1 ronald ronald 300586 2019-10-11 21:46 1570841190.M781954P399602.br472.hostgator.com.br,S=300586,W=304721:2,
-rw-r----- 1 ronald ronald 299949 2019-10-11 21:47 1570841258.M111576P402416.br472.hostgator.com.br,S=299949,W=304075:2,
-rw-r----- 1 ronald ronald 305696 2019-10-11 21:48 1570841322.M811059P402416.br472.hostgator.com.br,S=305696,W=309901:2,
-rw-r----- 1 ronald ronald 298530 2019-10-11 21:49 1570841388.M749590P402416.br472.hostgator.com.br,S=298530,W=302637:2,
-rw-r----- 1 ronald ronald 295861 2019-10-11 21:50 1570841452.M450157P402416.br472.hostgator.com.br,S=295861,W=299931:2,
-rw-r----- 1 ronald ronald 299296 2019-10-11 21:51 1570841517.M363735P407440.br472.hostgator.com.br,S=299296,W=303413:2,
-rw-r----- 1 ronald ronald 298266 2019-10-11 21:53 1570841581.M704762P407486.br472.hostgator.com.br,S=298266,W=302369:2,
-rw-r----- 1 ronald ronald 294032 2019-10-11 21:54 1570841642.M46478P407486.br472.hostgator.com.br,S=294032,W=298077:2,
-rw-r----- 1 ronald ronald 300326 2019-10-11 21:55 1570841706.M4802P410758.br472.hostgator.com.br,S=300326,W=304457:2,
-rw-r----- 1 ronald ronald 308640 2019-10-11 21:56 1570841769.M154215P410758.br472.hostgator.com.br,S=308640,W=312885:2,
-rw-r----- 1 ronald ronald 313215 2019-10-11 21:57 1570841839.M665145P410758.br472.hostgator.com.br,S=313215,W=317523:2,
需要的是从该列表中提取的文本文件,其中只有第 7 列和第 8 列。
这怎么可能做到呢?
答案1
当然这已经是重复的但是:
ls [OPTIONS] | awk '{print $7,$8}' >file.txt
还有你可能不应该解析ls
。
(如果您的其中一个文件名中有空格,则就其而言,它实际上会成为两个单独的列awk
)