2

Here follows given ls output:

-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,

What is needed is a text file extracted from this list with only 7th and 8th columns of it.

How could this be done?

1
  • 1
    Don't Parse ls. Instead, use stat with --format or --printf options (GNU stat) or -f (BSD stat). That will let you print whichever file metadata you want, in any format you want. find's -printf option is another good alternative.
    – cas
    Oct 13 '19 at 5:23
1

Surely this is already a duplicate but:

ls [OPTIONS] | awk '{print $7,$8}' >file.txt

Also you probably shouldn't parse ls.

(if one of your filenames had a space in it, it would actually become two separate columns as far as awk is concerned)

1
  • Made some reading here about ls parsing, but may you explain clearly why ls command shouldn't be parsed?
    – Ronald71
    Oct 12 '19 at 23:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.