GreenLake Administration
- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Search and replace control chars
Operating System - HP-UX
1849977
Members
1939
Online
104049
Solutions
Forums
Categories
Company
Local Language
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Forums
Discussions
back
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
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Topic Options
- 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-10-2008 07:57 AM
04-10-2008 07:57 AM
Search and replace control chars
An application creates a multipage print file. There is a new page control character when starting a new page. I want to add a new line right after this new page character.
On vi, I see this char as ^L. If I edit the file interactively with vi, I’m able to create a new line with a global find and substitution like this
:g/^L/s//^L^M/
But when try doing the same on a shell script, it fails.
Using od –cb, ^L is displayed as \f and 014 octal.
Any hints why this is failing on any script type to add a new line after this control character?
On vi, I see this char as ^L. If I edit the file interactively with vi, I’m able to create a new line with a global find and substitution like this
:g/^L/s//^L^M/
But when try doing the same on a shell script, it fails.
Using od –cb, ^L is displayed as \f and 014 octal.
Any hints why this is failing on any script type to add a new line after this control character?
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-10-2008 08:53 AM
04-10-2008 08:53 AM
Re: Search and replace control chars
Hi Fidel:
# perl -pi -e 's/\014/\014\012/g' file
...will update the file inplace.
The ^M you show is really a carriage-return character (\015). If you truly want that, change the \012 to a \015 in the above, although properly, it should a \015 followed by a \012.
Regards!
...JRF...
# perl -pi -e 's/\014/\014\012/g' file
...will update the file inplace.
The ^M you show is really a carriage-return character (\015). If you truly want that, change the \012 to a \015 in the above, although properly, it should a \015 followed by a \012.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-10-2008 08:58 AM
04-10-2008 08:58 AM
Re: Search and replace control chars
Sweet!
Thanks for your nice reply.
Thanks for your nice reply.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-11-2008 01:20 AM
04-11-2008 01:20 AM
Re: Search and replace control chars
:g/^L/s//^L^M/
>But when try doing the same on a shell script, it fails.
How are you doing it in a script? With sed?
>Using od â cb, ^L is displayed as \f and 014 octal.
Yes, that's a formfeed.
>Any hints why this is failing on any script type to add a new line after this control character?
I've mentioned before that I can't enter a CR in the shell, only a linefeed. In vi, I can use control-V control-M and get it. Perhaps that's your issue?
>But when try doing the same on a shell script, it fails.
How are you doing it in a script? With sed?
>Using od â cb, ^L is displayed as \f and 014 octal.
Yes, that's a formfeed.
>Any hints why this is failing on any script type to add a new line after this control character?
I've mentioned before that I can't enter a CR in the shell, only a linefeed. In vi, I can use control-V control-M and get it. Perhaps that's your issue?
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
Company
Events and news
Customer resources
© Copyright 2026 Hewlett Packard Enterprise Development LP