- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- script that updates a file but in many directories
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-27-2004 05:59 AM
04-27-2004 05:59 AM
script that updates a file but in many directories
i have a .txt file called 'Master' and 75 user directories each containing the same 'Master' .txt file.
When i make changes to this 'Master' file i then have to copy & paste it into each of these 75 user directories.
So, my question is:
is there a script that can do all of this for me? A script that looks for changes in the 'Master' file and, if it detects changes, updates the 'Master' file in the 75 user directories.
Thank you for your time,
Nick
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-27-2004 06:28 AM
04-27-2004 06:28 AM
Re: script that updates a file but in many directories
#!/usr/bin/sh
cd /topdir
find . ! -newer /your/Master.txt -name Master.txt -print | xargs -n1 cp /your/Master.txt
HTH
-- Rod Hills
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-27-2004 06:32 AM
04-27-2004 06:32 AM
Re: script that updates a file but in many directories
assuming the file name is the same in all users directories. And all the users directories fall under a certain path, that is separate from your master file. If not it would be a little more complex, but still possible.
I wouldn't worry about making something watch for changes, although you could add something in cron to do that.
a simple loop like to following should get you started.
for file in `find /home -name master.txt`
do
cp master $file
done
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-27-2004 06:41 AM
04-27-2004 06:41 AM
Re: script that updates a file but in many directories
ln -s /master_dir/Master.txt /user1_dir
ln -s /master_dir/Master.txt /user2_dir
...
Then opening /user1_dir/Master.txt will really open /master_dir/Master.txt . Any change to that file will immediately be seen by every link. (The permissions come from the real file rather than the owner and permissions of the link. That means that all users would need to be able to open the single Master.txt file.)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-27-2004 07:16 AM
04-27-2004 07:16 AM
Re: script that updates a file but in many directories
Hai
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-27-2004 10:51 AM
04-27-2004 10:51 AM
Re: script that updates a file but in many directories
If all the Master.txt files are in the same file system, you can try,
ln /master_dir/Master.txt /user1_dir/Master.txt
link without -s option, so if you delete the master file, no problem, all are master, and all are the same.
Frank.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-27-2004 11:13 AM
04-27-2004 11:13 AM