- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Microsoft
- >
- Re: DOS 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
Discussions
Discussions
Forums
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
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
тАО07-31-2006 07:19 AM
тАО07-31-2006 07:19 AM
Re: DOS help
In Perl, you could substitute the string PRODUCTION for that of DEVELOP in your file "inplace" like this:
# perl -pi.old -e 's/\bDEVELOP\b/PRODUCTION/gi' file
This substitution would occur case-insensitvely. That is, the "i" following the string PRODUCTION means to match the string DEVELOP case-insensitively, and replace every occurance ((g)lobally) with "PRODUCTION".
The "\b" is a "boundry" so that DEVELOP is replaced by PRODUCTION but not DEVELOPMENT.
The switch '-pi.old' tells Perl to print and perform an inplace edit, first preserving a a copy of 'file' as 'file.old'.
As you can otherwise see, the substitution syntax is similar to 'sed'.
If you want to begin to learn Perl, a good start would be O'Reilly's "Learning Perl (3rd Ed)" by by Randal L. Schwartz and Tom Phoenix.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-31-2006 03:54 PM
тАО07-31-2006 03:54 PM
Re: DOS help
I am not recommending this solution. But for the "old" dos edlin fans this worked on
my Windows 2000 [Version 5.00.2195] box
I could not resist showing this:
Contents of text file to fix called test.txt:
C:\>type test.txt
This is a DEVPLOP system
This is a DEVPLOP system
This is a DEVPLOP system
THIS is a DEVPLOP system
C:\>
The above file is CRLF terminated..
I then create a file called doit, with edlin using the following line commands:
C:\>edlin doit
New file
*i
1:*1RDEVPLOP^ZPRODUCTION
2:*E
3:*^Z
e
C:\>
^Z is "Ctrl"Z
I then ran the following command to change the test.txt "text":
C:\>edlin test.txt < doit
End of input file
*1RDEVPLOP^ZPRODUCTION
1:*This is a PRODUCTION system
2: This is a PRODUCTION system
3: This is a PRODUCTION system
4: THIS is a PRODUCTION system
*E
C:\>
edlin renamed lower case test.txt to upper case TEST.TXT (and left a TEST.BAK copy)
Thanks for letting me use edlin for the first time in many years...
Rory
On my box edlin can be found at
C:\WINNT\system32\edlin.exe
C:\WINNT\system32\dllcache\edlin.exe
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-31-2006 07:15 PM
тАО07-31-2006 07:15 PM
Re: DOS help
;)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-31-2006 08:08 PM
тАО07-31-2006 08:08 PM
Re: DOS help
I couldn't really believe it myself. I even found edlin on my XP machine.. I truly have not used it for many years... (I do admit that I have recently used UNIX ed ...)
Do you think this revelation might be a MS plot to still our souls?
:-}
Rory
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-01-2006 02:53 AM
тАО08-01-2006 02:53 AM
Re: DOS help
But I cannot make words replace, either using dos sed, or perl command.
All DEVELOP words remains. Execution went through without error. Syntac is corret. Would that be the windows/dos character issue?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-01-2006 03:10 AM
тАО08-01-2006 03:10 AM
Re: DOS help
the perl will work for shure.
- Did you get any error messages?
- You can create a small file as a test case and try.
- You can give as one matching line of that file for inspection.
mfG Peter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-01-2006 03:12 AM
тАО08-01-2006 03:12 AM
Re: DOS help
This should work under Windows:
perl -i.save -p -e "s/DEVPLOP/PRODUCTION/g" file1 file2 ...
Note the double vs. single quotes.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-01-2006 04:00 AM
тАО08-01-2006 04:00 AM
Re: DOS help
Thanks for the help. It works, and it happens when I try "perl -pi.old -e 's/\bDEVELOP\b/PRODUCTION/gi' file
", which failed to replace any.
Yours is simpler and working.
But everybody's efforts are very appreciated.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-01-2006 04:13 AM
тАО08-01-2006 04:13 AM
Re: DOS help
Consider a file with these lines:
this is DEVELOPMENT DEVELOP
DEVELOP
DEVELOPMENT
# perl -ple 's/\bDEVELOP\b/PRODUCTION/gi' file
...produces:
this is DEVELOPMENT PRODUCTION
PRODUCTION
DEVELOPMENT
...That is, "words" matching DEVELOP are replaced, not any string containing this sequence. You were not very clear defining your requiremnents.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-01-2006 04:40 AM
тАО08-01-2006 04:40 AM