Copying all of the files that are owned by the user.

Copying all of the files that are owned by the user.

am 30.03.2008 12:22:01 von Tom Gur

Hi,

How do I copy all of the files that are owned by the user ?
i.e copy all of the files in /tmp that are owned by the user who
performs the command/

Thanks,
Tom Gur

Re: Copying all of the files that are owned by the user.

am 30.03.2008 12:44:45 von PK

Tom Gur wrote:

> Hi,
>
> How do I copy all of the files that are owned by the user ?
> i.e copy all of the files in /tmp that are owned by the user who
> performs the command/

Assuming the user is the one returned by "whoami", then

u=`whoami`
find /tmp -user "$u" -exec cp '{}' /dest/dir \;

--
All the commands are tested with bash and GNU tools, so they may use
nonstandard features. I try to mention when something is nonstandard (if
I'm aware of that), but I may miss something. Corrections are welcome.

Re: Copying all of the files that are owned by the user.

am 30.03.2008 13:12:03 von medomoe

On Mar 30, 11:22 am, Tom Gur wrote:
> Hi,
>
> How do I copy all of the files that are owned by the user ?
> i.e copy all of the files in /tmp that are owned by the user who
> performs the command/
>
> Thanks,
> Tom Gur

Hello ,
Also you can do the following

find / -name $(username) |xrags -i cp -r {} $(destination)

Re: Copying all of the files that are owned by the user.

am 30.03.2008 14:05:18 von Tom Gur

On Mar 30, 2:12 pm, "medo...@gmail.com" wrote:
> On Mar 30, 11:22 am, Tom Gur wrote:
>
> > Hi,
>
> > How do I copy all of the files that are owned by the user ?
> > i.e copy all of the files in /tmp that are owned by the user who
> > performs the command/
>
> > Thanks,
> > Tom Gur
>
> Hello ,
> Also you can do the following
>
> find / -name $(username) |xrags -i cp -r {} $(destination)

Thanks !

Re: Copying all of the files that are owned by the user.

am 30.03.2008 23:12:51 von Rikishi 42

On 2008-03-30, medomoe@gmail.com wrote:
>
>
> On Mar 30, 11:22 am, Tom Gur wrote:
>> Hi,
>>
>> How do I copy all of the files that are owned by the user ?
>> i.e copy all of the files in /tmp that are owned by the user who
>> performs the command/
>>
>> Thanks,
>> Tom Gur
>
> Hello ,
> Also you can do the following
>
> find / -name $(username) |xrags -i cp -r {} $(destination)

That would only return files who have the same name as the user, wouldn'it?
He wants the files owned by the user.

--
There is an art, it says, or rather, a knack to flying.
The knack lies in learning how to throw yourself at the ground and miss.
Douglas Adams

Re: Copying all of the files that are owned by the user.

am 31.03.2008 02:04:49 von Steve Youngs

=2D----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
NotDashEscaped: You need GnuPG to verify this message

* pk writes:

> Tom Gur wrote:
>> How do I copy all of the files that are owned by the user ?
>> i.e copy all of the files in /tmp that are owned by the user who
>> performs the command/

> Assuming the user is the one returned by "whoami", then

> u=3D`whoami`
> find /tmp -user "$u" -exec cp '{}' /dest/dir \;

Is there any point/advantage to using a variable there? I would have
simply...=20

find /tmp -user $(whoami) -type f -exec cp {} /dest \;

The `-type f' so you don't run into trouble if there are directories or
other special files.

=2D-=20
|---------------------|
| SXEmacs - The only _______ you'll ever need. |
| Fill in the blank, yes, it's THAT good! |
|---------------------------------------|
=2D----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.8 (GNU/Linux)
Comment: The SXEmacs Project
Comment: EMchat - The SXEmacs IM client

iEYEARECAAYFAkfwKqIACgkQHSfbS6lLMAPHrQCguuGsiY2vcstMtOwuXK6e s9qe
9DgAoIYEXGTrcQLApy+elsP04WZcCJfJ
=3DuRGR
=2D----END PGP SIGNATURE-----

Re: Copying all of the files that are owned by the user.

am 31.03.2008 09:50:20 von PK

Steve Youngs wrote:

> Is there any point/advantage to using a variable there? I would have
> simply...
>
> find /tmp -user $(whoami) -type f -exec cp {} /dest \;
>
> The `-type f' so you don't run into trouble if there are directories or
> other special files.

Thanks, that's probably better.

--
All the commands are tested with bash and GNU tools, so they may use
nonstandard features. I try to mention when something is nonstandard (if
I'm aware of that), but I may miss something. Corrections are welcome.