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
scripting newbie needs help irishluck66 Shell Programming and Scripting 0 05-23-2008 12:22 PM
Shell Scripting Newbie mattyjim2 UNIX for Dummies Questions & Answers 1 10-11-2007 07:20 AM
Shell scripting newbie - please be gentle. charliemp3 Shell Programming and Scripting 2 08-01-2007 02:25 PM
shell scripting newbie question jazzman UNIX for Dummies Questions & Answers 2 12-29-2006 09:33 AM
Newbie - Need help in bash scripting coolbib Shell Programming and Scripting 4 08-11-2002 09:28 PM

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 10-19-2007
Kymmers7 Kymmers7 is offline
Registered User
  
 

Join Date: Oct 2007
Posts: 6
Scripting Newbie

Seems simple but I am having difficulty with this one: I am trying to write a single command line argument (which will be a path) - the program should print out the owner of the path.
I can not get anything I write to run.
Please help.
  #2 (permalink)  
Old 10-19-2007
matrixmadhan matrixmadhan is offline Forum Advisor  
Technorati Master
  
 

Join Date: Mar 2005
Location: leaf node in B+ tree
Posts: 2,960
Quote:
Originally Posted by Kymmers7 View Post
Seems simple but I am having difficulty with this one: I am trying to write a single command line argument (which will be a path) - the program should print out the owner of the path.
I can not get anything I write to run.
Please help.


Sorry, could you please be more descriptive.

To find the owner of the path. -- path could either be a file or a directory.

Did you mean finding the owner of the file or a directory ?
  #3 (permalink)  
Old 10-19-2007
Kymmers7 Kymmers7 is offline
Registered User
  
 

Join Date: Oct 2007
Posts: 6
Yes, find owner of file or directory to print that information out once the script is run. I know the command to get the information, I am having difficulty writing the command within a script for a user to supply a file/directory to get that information.
  #4 (permalink)  
Old 10-19-2007
matrixmadhan matrixmadhan is offline Forum Advisor  
Technorati Master
  
 

Join Date: Mar 2005
Location: leaf node in B+ tree
Posts: 2,960

Code:
#! /bin/zsh

if [ $# -eq 0 ]
then
  echo "USAGE: script file/directory"
  exit 1
fi

if [ -f $1 ]
then
  echo "Owner of $1 : `ls -l $1 | awk '{ print $3 }'`"
else
  echo "Owner of $1 : `ls -ld $1 | awk '{ print $3 }'`"
fi

exit 0

  #5 (permalink)  
Old 10-19-2007
Kymmers7 Kymmers7 is offline
Registered User
  
 

Join Date: Oct 2007
Posts: 6
Does it matter if it is for the C Shell?
  #6 (permalink)  
Old 10-19-2007
ghostdog74 ghostdog74 is offline Forum Advisor  
Registered User
  
 

Join Date: Sep 2006
Posts: 2,558
if you have GNU find


Code:
find /path -printf "File:%f - Owner:%u\n"

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 11:30 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