You are not logged in.

#1 2009-04-28 16:16:37

loudtiger
Member
Registered: 2009-01-08
Posts: 68

simple cmd line help

not sure this is the forum to post this in, but here goes:

say i wanted to chown a bunch of files with a criteria. how would i do that?

i was thinking to chown today's modified files, for example, i would do something like

ls -la | grep "2009-04-28" > chown me

or something to that effect. obviously that's not the right line though. can someone get me pointed in the right direction? or a better way?

thanks for all of your help

Offline

#2 2009-04-28 16:28:43

Procyon
Member
Registered: 2008-05-07
Posts: 1,819

Re: simple cmd line help

man find

It can both check for modification time with -mtime and run a command on the found file with -exec

Offline

#3 2009-04-28 17:45:49

brisbin33
Member
From: boston, ma
Registered: 2008-07-24
Posts: 1,796
Website

Re: simple cmd line help

comon Procyon, that's no fun!

ls -la | grep "2009-04-28" | awk '{print $8}' | while read file; do chown me $file; done

just kidding, find is definitely the way to go smile

Offline

#4 2009-04-29 14:54:16

loudtiger
Member
Registered: 2009-01-08
Posts: 68

Re: simple cmd line help

sweet, this is perfect. thanks guys

Offline

#5 2009-04-29 15:55:57

klixon
Member
From: Nederland
Registered: 2007-01-17
Posts: 525

Re: simple cmd line help

brisbin33 wrote:

comon Procyon, that's no fun!

ls -la | grep "2009-04-28" | awk '{print $8}' | while read file; do chown me $file; done

just kidding, find is definitely the way to go smile

pftt... loose the grep... it will save you milliseconds! cool

ls -la | awk '/2009-04-28/ {print $8}' | while read file; do chown me $file; done

Stand back, intruder, or i'll blast you out of space! I am Klixon and I don't want any dealings with you human lifeforms. I'm a cyborg!

Offline

#6 2009-04-29 16:46:54

brisbin33
Member
From: boston, ma
Registered: 2008-07-24
Posts: 1,796
Website

Re: simple cmd line help

@klixon

haha indeed! plus you could be more targeted

ls -la | awk '{if ($6 == "2009-04-28") print $8}' | while read file; do chown me $file; done

oneupsmanship ftw!

Offline

Board footer

Powered by FluxBB