The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM
Home Forums Register Rules & FAQ Members List Arcade Search Today's Posts Mark Forums Read


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


Other UNIX.COM Threads 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 08:30 AM
How to backup /home directories? kingsan SUN Solaris 1 05-03-2006 02:41 PM
Delete old home directories munch UNIX for Dummies Questions & Answers 2 03-01-2006 09:16 PM
HACMP users home directories zz2kzq AIX 1 02-21-2006 11:22 AM
home network not working! boris888 IP Networking 2 05-14-2002 07:10 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-15-2008
Registered User
 

Join Date: May 2008
Posts: 24
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiReddit! Stumble this Post!Spurl this Post!
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-15-2008 at 09:14 PM.
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 05-15-2008
Registered User
 

Join Date: May 2008
Posts: 24
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiReddit! Stumble this Post!Spurl this Post!
edited for a little more info.
Reply With Quote
  #3 (permalink)  
Old 05-15-2008
Registered User
 

Join Date: Apr 2008
Location: Bangalore
Posts: 120
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiReddit! Stumble this Post!Spurl this Post!
To list all the directories ,

In solaris , u can use dir command.

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

Thanks
Penchal
Reply With Quote
  #4 (permalink)  
Old 05-15-2008
Registered User
 

Join Date: May 2008
Posts: 24
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiReddit! Stumble this Post!Spurl this Post!
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?
Reply With Quote
  #5 (permalink)  
Old 05-15-2008
Registered User
 

Join Date: May 2008
Posts: 24
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiReddit! Stumble this Post!Spurl this Post!
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
Reply With Quote
Google UNIX.COM
Reply



Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

vB 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 -7. The time now is 03:30 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger

Search Engine Optimization by vBSEO 3.1.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102