[comp.unix.questions] Half of a ls -l ?

robby@nuchat.sccsi.com (Robert Oliver Jr.) (05/12/91)

Hi there,
 
  Has anybody out there ever printed out the size,date and name of a file
without the permitions and owners just the size,date & name.  I would like 
to know how you did it!  
 
                                                    Robert Oliver
                                                    robby@nuchat.sccsi.com

toma@swsrv1.cirr.com (Tom Armistead) (05/13/91)

In article <1991May12.085633.10066@nuchat.sccsi.com> robby@nuchat.sccsi.com (Robert Oliver Jr.) writes:
>Hi there,
> 
>  Has anybody out there ever printed out the size,date and name of a file
>without the permitions and owners just the size,date & name.  I would like 
>to know how you did it!  
> 
>                                                    Robert Oliver
>                                                    robby@nuchat.sccsi.com


How about this?
    $ ls -l | awk  '{ printf "%6s  %s %2s %s  %s\n",$5,$6,$7,$8,$9 }'

Tom
-- 
Tom Armistead - Software Services - 2918 Dukeswood Dr. - Garland, Tx  75040
===========================================================================
toma@swsrv1.cirr.com                {egsner,letni,ozdaltx,void}!swsrv1!toma

phil@ux1.cso.uiuc.edu (Phil Howard KA9WGN) (05/13/91)

robby@nuchat.sccsi.com (Robert Oliver Jr.) writes:

>  Has anybody out there ever printed out the size,date and name of a file
>without the permitions and owners just the size,date & name.  I would like 
>to know how you did it!  

Assuming you want time with the date, you can pipe "ls -l" through this
or some approximation of it to match your ls's output format:

----CUT-HERE--------CUT-HERE--------CUT-HERE--------CUT-HERE--------CUT-HERE----
#!/usr/local/bin/awk -f
{
    if( NF>7 ) {
        z=substr("         ",length($4)) $4;
        z=z substr("   ",length($5)) $5;
        z=z substr("  ",length($6)) $6;
        z=z substr("     ",length($7)) $7;
        z=z " " $8;
        print z;
    };
};
----CUT-HERE--------CUT-HERE--------CUT-HERE--------CUT-HERE--------CUT-HERE----

If you don't want the time, leave out the appropriate field.
If you new awk is somewhere else, change the first line.
Gawk may work, too, but I didn't try it.

Watch out for some versions of ls that, when faced with a very high link
count, will jam the link count number and the privileges together as one
single field.  To avoid that you might have to extract the files based on
a combination of column number and whitespace, rather than whitespace alone.
-- 
 /***************************************************************************\
/ Phil Howard -- KA9WGN -- phil@ux1.cso.uiuc.edu   |  Guns don't aim guns at  \
\ Lietuva laisva -- Brivu Latviju -- Eesti vabaks  |  people; CRIMINALS do!!  /
 \***************************************************************************/

dfpedro@uswnvg.UUCP (Donn Pedro) (05/16/91)

In article <1991May12.085633.10066@nuchat.sccsi.com>, robby@nuchat.sccsi.com (Robert Oliver Jr.) writes:
> Hi there,
>  
>   Has anybody out there ever printed out the size,date and name of a file
> without the permitions and owners just the size,date & name.  I would like 
> to know how you did it!  
>  
>                                                     Robert Oliver
>                                                     robby@nuchat.sccsi.com

Did something like that just the other day.

Here is the output of the ls -l command.

$> ls -l

-rw-r-----   1 dfpedro  news       12956 May  8 22:47 Articles
-rwx------   1 dfpedro  news        3626 Mar 13 14:53 bell_die
-rw-------   1 dfpedro  news        1707 Apr 23 15:05 bill
-rw-r-----   1 dfpedro  news        8416 May  1 06:38 cellular
-rw-r-----   1 dfpedro  news         942 May 15 12:19 dead.article
-rw-r-----   1 dfpedro  news        8827 Mar 13 09:38 flog
-rw-------   1 dfpedro  news        1947 Mar 15 09:30 lane.out

$> ls -l | awk '{print $5,$6, $7, $8, $9}'

12956 May  8 22:47 Articles
3626 Mar 13 14:53 bell_die
1707 Apr 23 15:05 bill
8416 May  1 06:38 cellular
942 May 15 12:19 dead.article
8827 Mar 13 09:38 flog
1947 Mar 15 09:30 lane.out

There you go.



	dfpedro@uswnvg.UUCP

jpr@jpradley.jpr.com (Jean-Pierre Radley) (05/21/91)

In article <1991May12.085633.10066@nuchat.sccsi.com> robby@nuchat.sccsi.com (Robert Oliver Jr.) writes:
>Hi there,
> 
>  Has anybody out there ever printed out the size,date and name of a file
>without the permitions and owners just the size,date & name.  I would like 
>to know how you did it!  

I've never done it, but if I needed to, I'd use sed, cut, awk, or expr.
Awk would be the clearest to understand.

Jean-Pierre Radley   Unix in NYC   jpr@jpr.com   jpradley!jpr   CIS: 72160,1341

antoine@cl.bull.fr (Antoine Haraoui) (05/27/91)

I suggest you try the following :

ll | sed -e "s/  */ /g" | cut -d" " -f3,5,6,7

I tried it and it works fine. You can still pipe it
to one more sed at the end to format the output the 
way you like it.

Antoine G. HARAOUI, Bull S.A.       e-mail: Antoine.Haraoui@cl.bull.fr
Software Development Methodology    tel   : (33-1) 3080 7629  Bulltel->2377629 
Av. Jean-Jaures, PC F30D01,         fax   : (33-1) 3080 7078  Bullfax->2377078 
78340 Les Clayes sous Bois, France