Working with multiple home directories.

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Working with multiple home directories.
# 1  
Old 05-16-2008
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:


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  
Old 05-16-2008
edited for a little more info. Smilie
# 3  
Old 05-16-2008
To list all the directories ,

In solaris , u can use dir command.

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

# 4  
Old 05-16-2008
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 Smilie

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  
Old 05-16-2008
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 Smilie
# 6  
Old 05-16-2008

Use this :

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

# 7  
Old 05-16-2008
Originally Posted by penchal_boddu

Use this :

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

awesome, Ill man awk now to learn what all it can do Smilie

Thanks for your help!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Deleting multiple directories inside multiple directories

Hi, Very unfamiliar with unix/linux stuff. Our admin is on vacation so, need help very quickly. I have directories (eg 40001, 40002, etc) that each have one subdirectory (01). Each subdir 01 has multiple subdirs (001, 002, 003, etc). They are same in each dir. I need to keep the top and... (7 Replies)
Discussion started by: kkouraus1
7 Replies

2. HP-UX

Home directories in packages

Hi, At my new company they use HP-UX on all the servers. They use Serviceguard to provide different packages, which are treated as if they where seperate systems. Therefore people log into packages instead of Host, and even the home directories live in the package. Now there are a different... (4 Replies)
Discussion started by: michas
4 Replies

3. Shell Programming and Scripting

cp -p /home/* home/exp/*.date not working please help

:( ---------- Post updated at 01:51 AM ---------- Previous update was at 01:50 AM ---------- Not working ---------- Post updated at 02:04 AM ---------- Previous update was at 01:51 AM ---------- cp -p /home/* home/exp/*.`date` i am using this (4 Replies)
Discussion started by: rishiraaz
4 Replies

4. UNIX for Dummies Questions & Answers

home directories not being created by useradd

greetings. I'm using debian lenny, bash shell environment. It is my understanding that by default, the useradd command should create subdirectories under the /home directory, with the same name as the user being created, but this is not happening. I checked useradd -D and it showed, among... (2 Replies)
Discussion started by: fguy
2 Replies

5. Shell Programming and Scripting

List /home directories in a file

Hi, i was looking at a unix paper i found and one of the tasks was to create a file called 'usernames' that contains a list of all directories in /home. This file should be located in the /home/userinfo directory. How would i go about doing this without changing directories from the home... (2 Replies)
Discussion started by: warlock129
2 Replies

6. Shell Programming and Scripting

check if multiple directories exist else create missing directories

Hi , I 'm trying to check if multiple directories exist on a server, if not create the missing ones and print " creating missing directory. how to write this in a simple script, I have made my code complex if ; then taskStatus="Schema extract directory exists, checking if SQL,Count and... (7 Replies)
Discussion started by: ramky79
7 Replies

7. UNIX for Dummies Questions & Answers

UNIX home directories

Hi All, Could someone help, am a complete beginner when it comes to UNIX. However I have been tasked with investigating automatic creation of UK unix home directories. Is someone able to help? Thanks in advance! (7 Replies)
Discussion started by: zainster
7 Replies

8. Solaris

How to backup /home directories?

I know that how to backup the home directories in sun sparc server. Firstly, umount the filesystem, Secondly, fsck the filesystem, Thirdly, ufsdump the filesystem. Anybody know how to type the full command line backup the /home directory? (1 Reply)
Discussion started by: kingsan
1 Replies

9. UNIX for Dummies Questions & Answers

Delete old home directories

I have a script that deletes obselete users from /etc/passwd then moves their home directories to another location. After 30 days, I need to delete the home directories that were moved to the new location. I would appreciate any ideas on how to delete the directories after the 30 days? (2 Replies)
Discussion started by: munch
2 Replies

10. AIX

HACMP users home directories

What would be the best approach to configure one external /home f/s in simple two node config and have concurrent access ? (1 Reply)
Discussion started by: zz2kzq
1 Replies
Login or Register to Ask a Question

Featured Tech Videos