The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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
moving directories to new directories on multiple servers mackdaddy07 Shell Programming and Scripting 0 04-06-2007 12:30 PM
How to backup /home directories? kingsan SUN Solaris 1 05-03-2006 06:41 PM
Delete old home directories munch UNIX for Dummies Questions & Answers 2 03-02-2006 01:16 AM
HACMP users home directories zz2kzq AIX 1 02-21-2006 03:22 PM
home network not working! boris888 IP Networking 2 05-14-2002 11:10 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 05-16-2008
trey85stang trey85stang is offline
Registered User
  
 

Join Date: May 2008
Posts: 70
Working with multiple home directories.

I need to rename a directory in every home directory on a given workstation. I am a newb to scripting so maybe thats why I cant exactly figure out how to correctly do this.

The first thing I need to be able to do to write this script is figure out how to list all the directorys (these are not actual home directorys).

Im using solaris so that may complicate things for me.

ls -d only lists "." so that command is worthless.. for this.

find /path/to/users -type d ; somewhat works but it also lists every directory past users. I cant seem to find a way to tell it to only look in the one directory.the output is the following:

/path/to/user1
/path/to/user1/dir1
/path/to/user1/dir2
/path/to/user2/
/path/to/user2/dir1
/path/to/user2/dir2

I need to only see /path/to/user1 and /path/to/user2.

Anyone have any ideas on else I could try? Also, if it matters, Im using solaris to work on/write this script.. but the actual script will be for OSX, a post install script for an application upgrade.

Last edited by trey85stang; 05-16-2008 at 01:14 AM..
  #2 (permalink)  
Old 05-16-2008
trey85stang trey85stang is offline
Registered User
  
 

Join Date: May 2008
Posts: 70
edited for a little more info.
  #3 (permalink)  
Old 05-16-2008
penchal_boddu penchal_boddu is offline
Registered User
  
 

Join Date: Apr 2008
Location: Bangalore
Posts: 127
To list all the directories ,

In solaris , u can use dir command.

Even u can use this : ls -ltr | grep "^d"

Thanks
Penchal
  #4 (permalink)  
Old 05-16-2008
trey85stang trey85stang is offline
Registered User
  
 

Join Date: May 2008
Posts: 70
awesome penchal!

ls -ltr | grep "^d" | cut -c55-75

will work! Ill see if I can get what I want with dir without having to crep and cut as well

edit: On second though.. is there a way to just print everything from the 55 characters spot to the last character on the line? I think my variables with cut -c55-75 would include spaces tailed at the end? Im thinking tr could be used to do that.. but it would just make the command that much longer?
  #5 (permalink)  
Old 05-16-2008
trey85stang trey85stang is offline
Registered User
  
 

Join Date: May 2008
Posts: 70
ls -ltr | grep "^d" | cut -c55-75 | tr -d ' '

??? Is that too long of a command to throw in a script as a vairable? I dont think so.. but im still newbish to this
  #6 (permalink)  
Old 05-16-2008
penchal_boddu penchal_boddu is offline
Registered User
  
 

Join Date: Apr 2008
Location: Bangalore
Posts: 127
Hi,

Use this :

ls -ltr | grep "^d" | awk -F" " '{print $NF}'


Thanks
Penchal
Closed Thread

Bookmarks

Tags
solaris

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 01: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