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 > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Tar only the Directories and Sub Directories Andysundar UNIX for Dummies Questions & Answers 3 06-01-2008 08:54 PM
Listing directories and sub directories jinxor UNIX for Advanced & Expert Users 3 03-11-2008 10:27 AM
moving directories to new directories on multiple servers mackdaddy07 Shell Programming and Scripting 0 04-06-2007 11:30 AM
directories arunkumar_mca UNIX for Dummies Questions & Answers 2 10-14-2004 03:23 AM
du -ks on certain directories only Shambo Shell Programming and Scripting 1 09-05-2002 04:41 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 06-20-2003
sureshy sureshy is offline
Registered User
  
 

Join Date: Sep 2001
Location: UK
Posts: 25
cp to all directories.

SCO UnixWare 7

Hi friends,

I have experimented with various loops but can't seem to get it right.

I have a file which I need to copy into all users home directories.

Is there an easy way of doing this ?

Thanks

Suresh
  #2 (permalink)  
Old 06-20-2003
thehoghunter thehoghunter is offline
Registered User
  
 

Join Date: Jan 2002
Location: Florida
Posts: 84
You might try this....


$ find /yourtophome -type d -exec cp /tmp/mycpfile {} \;

Only drawback, it puts it into EVERY directory recursively

/home/user/saved/mycpfile
/home/user/junk/mycpfile
/home/user/mycpfile

Otherwise, post your script or at least what you are attempting to do this in (shell).

Here is a hint in csh (which no one usually uses)

%pwd
/home
% foreach xx ( `ls -1d ./*`)
cp /tmp/mycpfile $xx/mycpfile
end
%

Last edited by thehoghunter; 06-20-2003 at 11:30 AM..
  #3 (permalink)  
Old 06-20-2003
sureshy sureshy is offline
Registered User
  
 

Join Date: Sep 2001
Location: UK
Posts: 25
Thanks - you're a star!!
  #4 (permalink)  
Old 06-20-2003
Perderabo's Avatar
Perderabo Perderabo is offline Forum Staff  
Unix Daemon
  
 

Join Date: Aug 2001
Location: Ashburn, Virginia
Posts: 9,111
You can get list of home directories with:
awk -F: '{print $6}' < /etc/passwd

so

cp somefile `awk -F: '{print $6}' < /etc/passwd | sort -u`
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 08:15 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