The UNIX and Linux Forums  


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



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

Closed Thread
English Japanese Spanish French German Portuguese Italian Powered by Powered by Google
 
Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 04-15-2008
Registered User
 

Join Date: Apr 2008
Posts: 23
whats wrong with this code

ls -ld | grep $1 /etc/passwd | cut -d: -f6

i need see the content...
  #2 (permalink)  
Old 04-15-2008
DukeNuke2's Avatar
Soulman
 

Join Date: Jul 2006
Location: Germany, Berlin
Posts: 3,216
$1 is the first argument of a command... i don't understand what you want to achieve with the above...
  #3 (permalink)  
Old 04-15-2008
Moderator
 

Join Date: Feb 2007
Location: The Netherlands
Posts: 4,670
If you want to ls for directories of the homedirectory of user $1:


Code:
ls -ld $(grep "$1" /etc/passwd | cut -d: -f6)

Regards
  #4 (permalink)  
Old 04-15-2008
Registered User
 

Join Date: Sep 2006
Location: Mysore, India
Posts: 191
Can you please explain a bit what you are trying to achieve. What string are you searching in the passwd file?
  #5 (permalink)  
Old 04-15-2008
cfajohnson's Avatar
Shell programmer, author
 

Join Date: Mar 2007
Location: Toronto, Canada
Posts: 2,434
Quote:
Originally Posted by Franklin52 View Post
If you want to ls for directories of the homedirectory of user $1:


Code:
ls -ld $(grep "$1" /etc/passwd | cut -d: -f6)

There's no need to look at /etc/passwd or to use an external command (unless your shell doesn't have printf built in):


Code:

eval "printf '%s\n' ~$1/*/"

Sponsored Links
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 Off


More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
tell me whats wrong with this nadman123 Shell Programming and Scripting 1 04-15-2008 12:58 AM
tell me whats wrong in this? nadman123 Shell Programming and Scripting 1 04-10-2008 02:11 AM
Whats wrong with this script? kayarsenal Shell Programming and Scripting 2 08-25-2006 10:58 AM
Whats wrong with the mv command dsravan Shell Programming and Scripting 0 08-10-2006 04:30 PM
whats wrong with this awk??? george_ Shell Programming and Scripting 5 04-04-2006 05:58 AM



All times are GMT -4. The time now is 01:04 PM.


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