- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Script Help
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
03-19-2007 05:39 AM
03-19-2007 05:39 AM
Script Help
Example : abc@xyz.com .. I need to change xyz.com to def.com for all the files on the system.( I need to avoid binaries and log files though )
thanks,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2007 06:01 AM
03-19-2007 06:01 AM
Re: Script Help
Sed can then easily do the editing -- although I would do all of this in Perl.
Learn to clearly define your problem and then the solutions become much more obvious.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2007 06:05 AM
03-19-2007 06:05 AM
Re: Script Help
thanks,
hunki
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2007 06:09 AM
03-19-2007 06:09 AM
Re: Script Help
You could use the following pieces. I assume that by "log" files you mean those ending with a ".log" extension, although this is easily changed:
# perl -MFile::Find -le 'find(sub{print $File::Find::name if m/.+\.log/ && -f $_ && -T _}, @ARGV)' /path > filelist
# perl -pi.old -e 's/abc\@xyz.com/def\@xyz.com/g' `cat filelist`
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2007 07:00 AM
03-19-2007 07:00 AM
Re: Script Help
the command is giving me all log files as output which I dont require. I want to search for all files containing "@abc.com" on the system except for log and binary files and then replace them with "@xyz.com" since the company domain name changed.
thanks,
hunki
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2007 07:07 AM
03-19-2007 07:07 AM
Re: Script Help
OK, I had it backwards. To _skip_ files ending in ".log" negate (with '!') the condition. Thus:
# perl -MFile::Find -le 'find(sub{print $File::Find::name if ! m/.+\.log/ && -f $_ && -T _}, @ARGV)' /path > filelist
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2007 08:11 AM
03-19-2007 08:11 AM
Re: Script Help
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2007 08:15 AM
03-19-2007 08:15 AM
Re: Script Help
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2007 08:19 AM
03-19-2007 08:19 AM
Re: Script Help
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2007 08:32 AM
03-19-2007 08:32 AM
Re: Script Help
I provided *two* Perl snippets. The first simply gathers Ascii files while skipping files with ".log" in their name.
I made NO PROVISION to filter any farther than that.
The second Perl script does the actual replacement (if any) while preserving the original files as ".old". It uses (as input) the output generated by the first script.
Between the two, you have the hard work done for you. You can filter (reduce) the output from the first step (e.g. with 'grep') or you can use it directly with the second script if it fits your needs.
I didn't write a full-blown script but offered you re-useable pieces.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2007 08:38 AM
03-19-2007 08:38 AM
Re: Script Help
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2007 08:48 AM
03-19-2007 08:48 AM
Re: Script Help
I might note that the second Perl script updates "in-place" while making a backup copy of the original file as "*.old".
In the event that no matching patterns are found, the new file and the original would remain identical in content, although the 'mtime' of the current file would be changed to the current date/time since in truth it is a new file.
Regards!
...JRF...