need script to process ls-l command

ne1 know how i can do this????

a script that process the output of UNIX command ls -l

cheers

How do you desire to process it?

do u think it would be best to process the list into a file

i.e. ls-l>sinner (sinner name of file)

but if i do this how can i add it into a script

im guessin but will it be somethin like this

#!/usr/bin/csh
#send list to file
code..................................
#read file
code....................................

sinner your missing the point of Tuxs response.

what are you trying to do w/ the ls -l output?
what are your program requirements?
what is your final goal for this project?

well i need a script that process the output of UNIX command ls -l, where the script takes, the long listing and reduces it to print the size, name of the file, total number of bytes and number of ordinary-files listed.

Using awk,

ls -l | awk '{print $1, $2, $3, $4}'

where $1, $2 , $3 are the fields that you wish to print. Awk will delimit each field in the listing of "ls -l" by a space. Each successive field can be printed by providing the field number. So print $1, $2, $3, $4 will print out the first 4 fields. Change the field values to correspond to the field positions you want printed.

On second thought, this seems too much like homework. If it is, you have enough to go on to figure out the rest :wink:

cheers bro owe u 1

does ne1 know how list the ordinary files not directories

been through man pages and there is no command

as the command to display directoy only is ls -d */

pipe the output of your ls -l command to grep -v ^d

that says do not display any entries that have the directory attribute set.

cheers m8 it worked

only got 1 thing left to do is to calculate the total number of bytes

should this be added into another file to calculate the total number of bytes

you could wrap the whole statement up into a loop then execute the ls portion on each specific file while you are doing that you can start the counter to add up all the bytes.

the more and more this progresses the more and more it sounds like homework.

ok i think i'm on the right track

i've changed the file, i have a file called C which has the following code:

{n++;t+=$4};END{print "total number of files "n " " "total size"t
print $5, $9}

the code to run on command line is :

Ls -l | grep -v ^d | awk -f C

my problem is that it only print one file out of the list. i have 19 oridinary files and only the last file is being printed. how can i make it print out the entire list cuz @ the moment the code which prints from the list is "print $5, $9"

can ne1 help me with this small problem

ok guyz i got it done

u can do whatever u want to do with this post

but i'd like to thanx the following members :

google

Optimus_P

for helping me complete this task

l8er bros:p