Half of a ls -l ?
Phil Howard KA9WGN
phil at ux1.cso.uiuc.edu
Mon May 13 09:22:13 AEST 1991
robby at 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 at ux1.cso.uiuc.edu | Guns don't aim guns at \
\ Lietuva laisva -- Brivu Latviju -- Eesti vabaks | people; CRIMINALS do!! /
\***************************************************************************/
More information about the Comp.unix.questions
mailing list