checking files by type

checking files by type

am 24.09.2007 17:49:28 von obviouslyst

Hello folks,
I have a Linux file server with a couple of users, and I would like to
know what is the size of each .xls files and the owner.

somethink like
find / -iname *.xls > /tmp/xlsfiles
ls -l `cat /tmp/xls` | sort ????? by size by username ????

Thanks

Re: checking files by type

am 24.09.2007 17:56:51 von Janis Papanagnou

obviouslyst wrote:
> Hello folks,
> I have a Linux file server with a couple of users, and I would like to
> know what is the size of each .xls files and the owner.
>
> somethink like
> find / -iname *.xls > /tmp/xlsfiles
> ls -l `cat /tmp/xls` | sort ????? by size by username ????

Sort by size or by username?

Numerical sort of the fifth column: sort +4n

Janis

>
> Thanks
>

Re: checking files by type

am 24.09.2007 18:22:32 von Icarus Sparry

On Mon, 24 Sep 2007 17:56:51 +0200, Janis Papanagnou wrote:

> obviouslyst wrote:
>> Hello folks,
>> I have a Linux file server with a couple of users, and I would like to
>> know what is the size of each .xls files and the owner.
>>
>> somethink like
>> find / -iname *.xls > /tmp/xlsfiles
>> ls -l `cat /tmp/xls` | sort ????? by size by username ????
>
> Sort by size or by username?
>
> Numerical sort of the fifth column: sort +4n
>
> Janis
>
>
>> Thanks
>>

"find" has a "-ls" option so you don't need the temp file.

find / -iname '*.xls' -ls | sort -k6n -k4

It might be that your system has "locate" which consults a cached copy of
the output of the find, which will be very much faster if you can live
with the lag between when the cache was last generated and now. In this
case you will need to do something like "ls" to get all the info out, but
the speed gain will be considerable.

locate -0 -i '*.xls' | xargs -0 ls -l | sort -k4n -k2

Re: checking files by type

am 24.09.2007 18:22:49 von obviouslyst

On Sep 24, 4:56 pm, Janis Papanagnou
wrote:
> obviouslyst wrote:
> > Hello folks,
> > I have a Linux file server with a couple of users, and I would like to
> > know what is the size of each .xls files and the owner.
>
> > somethink like
> > find / -iname *.xls > /tmp/xlsfiles
> > ls -l `cat /tmp/xls` | sort ????? by size by username ????
>
> Sort by size or by username?
>
> Numerical sort of the fifth column: sort +4n
>
> Janis
>
>
>
> > Thanks

cool, it works perfect !!!
but... ups!!! the command
ls -l `cat /tmp/xls`
won't recognize the files or directories with spaces, how can I put
the "" at the begining and end of each line while doing the cat?
Thanks

Re: checking files by type

am 24.09.2007 18:24:49 von obviouslyst

That was "poli grigora" !!!
Aphgaristo poli

Re: checking files by type

am 24.09.2007 19:34:18 von Loki Harfagr

On Mon, 24 Sep 2007 16:22:49 +0000, obviouslyst wrote:

> On Sep 24, 4:56 pm, Janis Papanagnou
> wrote:
>> obviouslyst wrote:
>> > Hello folks,
>> > I have a Linux file server with a couple of users, and I would like
>> > to know what is the size of each .xls files and the owner.
>>
>> > somethink like
>> > find / -iname *.xls > /tmp/xlsfiles
>> > ls -l `cat /tmp/xls` | sort ????? by size by username ????
>>
>> Sort by size or by username?
>>
>> Numerical sort of the fifth column: sort +4n
>>
>> Janis
>>
>>
>>
>> > Thanks
>
> cool, it works perfect !!!
> but... ups!!! the command
> ls -l `cat /tmp/xls`
> won't recognize the files or directories with spaces, how can I put the
> "" at the begining and end of each line while doing the cat? Thanks

You'd probably better read the hint Icarus Sparry posted for you
and have a different start but just in case you'd like to
try it your way there's a possibility in something around this hint:

here's the space infected list of stuff:
------
$ cat /dev/shm/___
one one one
two two
three
four fie foe
fum
------

and, here's a dirty way to check you can read it "linely":
------
$ while read ll; do echo ":>${ll}" ; done < /dev/shm/___
:>one one one
:>two two
:>three
:>four fie foe
:>fum
------

To be compared to:
------
$ for ll in `cat /dev/shm/___` ; do echo ":>${ll}" ; done
:>one
:>one
:>one
:>two
:>two
:>three
:>four
:>fie
:>foe
:>fum
------

or:
------
$ IFS= ; for ll in `cat /dev/shm/___` ; do echo ":>${ll}" ; done
:>one one one
two two
three
four fie foe
fum
------

Re: checking files by type

am 25.09.2007 08:04:53 von Bill Marcum

Janis Papanagnou wrote:
>
>
> obviouslyst wrote:
>> Hello folks,
>> I have a Linux file server with a couple of users, and I would like to
>> know what is the size of each .xls files and the owner.
>>
>> somethink like
>> find / -iname *.xls > /tmp/xlsfiles
>> ls -l `cat /tmp/xls` | sort ????? by size by username ????
>
> Sort by size or by username?
>
> Numerical sort of the fifth column: sort +4n
>
> Janis
>
GNU ls has a sort by size option: ls -S

Re: checking files by type

am 25.09.2007 08:45:49 von mik3l3374

On Sep 24, 11:49 pm, obviouslyst wrote:
> Hello folks,
> I have a Linux file server with a couple of users, and I would like to
> know what is the size of each .xls files and the owner.
>
> somethink like
> find / -iname *.xls > /tmp/xlsfiles
> ls -l `cat /tmp/xls` | sort ????? by size by username ????
>
> Thanks

GNU find has printf option to print size : eg

find . -name "*.sh" -printf "%s:%p\n"|sort -n -k1

Re: checking files by type

am 25.09.2007 12:04:25 von obviouslyst

Excelent, thanks folks for all the help.
It works now!!!