The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
find size of folders and its subfolders with the Owner details bsandeep_80 UNIX for Advanced & Expert Users 5 04-15-2008 04:03 AM
Owner of file gets 'not owner' error for chgrp brizrobbo SUN Solaris 4 12-18-2007 05:30 PM
how to find the owner PID of open socket on Solaris9? sleepy_11 UNIX for Dummies Questions & Answers 1 12-11-2007 06:18 AM
Anyways to find sentences with data format and extract it??? cyberray Shell Programming and Scripting 4 10-30-2007 11:22 PM
extract data from a find string odogbolu98 Shell Programming and Scripting 2 05-15-2002 09:06 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 08-12-2008
tjay83 tjay83 is offline
Registered User
  
 

Join Date: Jan 2008
Posts: 98
how to extract owner from find command

hi
how can I extract the owner of the file from the find command that I used below

find /home -type f -atime +5

I tried something like this but didnt work.

find /home -type f -atime +5 -ls |cut -f5
  #2 (permalink)  
Old 08-12-2008
Franklin52 Franklin52 is online now Forum Staff  
Moderator
  
 

Join Date: Feb 2007
Posts: 4,314
One way:

Code:
find /home -type f -atime +5 -exec ls -l {} \;| awk 'print $4}'
Regards
  #3 (permalink)  
Old 08-12-2008
tjay83 tjay83 is offline
Registered User
  
 

Join Date: Jan 2008
Posts: 98
Quote:
Originally Posted by Franklin52 View Post
One way:

Code:
find /home -type f -atime +5 -exec ls -l {} \;| awk 'print $4}'
Regards
It worked,
but I dont undestand this
why do we use
-exec ls -l {} \;|
why not only ls -l
  #4 (permalink)  
Old 08-12-2008
Franklin52 Franklin52 is online now Forum Staff  
Moderator
  
 

Join Date: Feb 2007
Posts: 4,314
With the exec command the '{}' is replaced by the current file name, check the manpage of find.

Regards
  #5 (permalink)  
Old 08-12-2008
era era is offline Forum Advisor  
Herder of Useless Cats (On Sabbatical)
  
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,652
Actually if your find supports the -ls action, that's fine, too. The problem with cut is that it expects tab-delimited output; you can change that, but using awk instead might be simpler.
  #6 (permalink)  
Old 08-12-2008
tjay83 tjay83 is offline
Registered User
  
 

Join Date: Jan 2008
Posts: 98
thanks
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 08:37 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0