- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- replace control characters in a file
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
01-25-2008 07:46 AM
01-25-2008 07:46 AM
replace control characters in a file
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-25-2008 08:06 AM
01-25-2008 08:06 AM
Re: replace control characters in a file
You can use the dos2ux command, have a look at the man page.
# dos2ux old_name > new_name
Regards,
Robert-Jan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-25-2008 08:07 AM
01-25-2008 08:07 AM
Re: replace control characters in a file
Try to use dos2ux command.
#dos2ux file > newfile.
Regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-25-2008 08:08 AM
01-25-2008 08:08 AM
Re: replace control characters in a file
You can do:
# dos2ux file
# perl -pe 's%\r\n%\n%; s%\032%% if eof' file
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-25-2008 08:08 AM
01-25-2008 08:08 AM
Re: replace control characters in a file
dos2ux badfile > newfile
or in vi
s/$^V^M/g
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-25-2008 08:16 AM
01-25-2008 08:16 AM
Re: replace control characters in a file
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-25-2008 08:21 AM
01-25-2008 08:21 AM
Re: replace control characters in a file
Try this in vi.
:%s/^V^M//g
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-25-2008 08:25 AM
01-25-2008 08:25 AM
Re: replace control characters in a file
The ^V character is just for vi let you to type ^M command. The final command result in vi will lok like ":%s/^M//g"
Regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-25-2008 08:25 AM
01-25-2008 08:25 AM
Re: replace control characters in a file
Hmmm, why not dos2ux?
Are those carriage returns in the missle of the lines?
Anyway, in vi you can use
:1,$s/^M//
That ^M must be entered as control-V control-M
hth,
Hein.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-25-2008 08:29 AM
01-25-2008 08:29 AM
Re: replace control characters in a file
If there is more than 1 ^M on any line, then you'd need to add the 'g' at the end of the substitute command of course:
:1,$s/^M//g
That ^M must still be entered as control-V control-M
hth,
Hein.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-25-2008 08:31 AM
01-25-2008 08:31 AM
Re: replace control characters in a file
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-25-2008 08:37 AM
01-25-2008 08:37 AM
Re: replace control characters in a file
assuming the ones you want are at the end of the line, you want
1,$s/cntrl-Vcntrl-M$//g
the Cntrl-V "escapes" the Cntrl-M so it's taken as a literal, and the "$" in the pattern is an anchor for the end-of-line
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-25-2008 08:50 AM
01-25-2008 08:50 AM
Re: replace control characters in a file
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-25-2008 08:54 AM
01-25-2008 08:54 AM
Re: replace control characters in a file
such things as Ctrl-L (form-feed) are retained for printing page breaks, which you may still want.
usually what happens is a file is created in Windows as text. Transferring this file in binary mode to a Unix box results in the Windows-style CR/LF pairs being retained, while an ascii-mode transfer translates them.
Without knowing what the file contains / how created, I would hesitate to alter it further.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-25-2008 09:06 AM
01-25-2008 09:06 AM
Re: replace control characters in a file
I got the ^M's out now butv it is putting this in:
if sum -r </dev/null >/dev/null 2>&1
instead of:
if sum -r /dev/null 2>&1
and I assume other lines are probably
corrupt like that too.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-25-2008 09:16 AM
01-25-2008 09:16 AM
Re: replace control characters in a file
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-26-2008 02:56 AM
01-26-2008 02:56 AM
Re: replace control characters in a file
if sum -r </dev/null >/dev/null 2>&1
These are html formatting chars. You might want to use the right button to save the patch directly?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-15-2008 02:51 PM
04-15-2008 02:51 PM
Re: replace control characters in a file
Can you please let me know how to solve this issue.Currently i am facing same problem all of a sudden after server reboot .I am using CIFS/Samba to map my unix folders to windows.
TIA
Sri