- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: replacing /n with newline with ed.
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
тАО04-02-2002 06:11 AM
тАО04-02-2002 06:11 AM
replacing /n with newline with ed.
cat - << EOF | ed -s file-1
1,$ s/abc/xyz/
w file-2
q
EOF
how do i specify that i want to replace with a newline?
I've tried
cat - << EOF | ed -s file-1
1,$ s/\n/\r/g
w file-2
q
EOF
but that replaces the \n with the \r.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-02-2002 06:20 AM
тАО04-02-2002 06:20 AM
Re: replacing /n with newline with ed.
In ed or vi
type ControlVEnter which will show ^M
This is a new line.
Steve Steel
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-02-2002 06:22 AM
тАО04-02-2002 06:22 AM
Re: replacing /n with newline with ed.
By enter I mean the return key
Or type ControlVControlM
Steve Steel
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-02-2002 06:26 AM
тАО04-02-2002 06:26 AM
Re: replacing /n with newline with ed.
Under the context of the ed command you're trying you'll need to "escape" the slash just before the "r" that represents the carriage return.
So use double slash:
\and press return to change line (then you just finnish the line).
Instead of:
\n
Good Luck,
Rumagoso
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-02-2002 06:30 AM
тАО04-02-2002 06:30 AM
Re: replacing /n with newline with ed.
my post was victim of escaping!!!!
You should have seen:
\\that is double-slash instead of \\and
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-02-2002 06:38 AM
тАО04-02-2002 06:38 AM
Re: replacing /n with newline with ed.
I'm almost there...
My current command looks like this:
cat - << EOF | ed -s work.txt
1,$ s/
w work2.txt
q
EOF
all occurences of the letter n are replaced with carriage returns. Thats mostly what I want but the backslash stays in the file. How do I say that i want the backslash and the n to be replaced?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-02-2002 06:45 AM
тАО04-02-2002 06:45 AM
Re: replacing /n with newline with ed.
awk 'BEGIN{FS="/n"}{
for (i=1;i<=NF;i++){
printf "%s\n",$i^J }
printf "\n";
}' infile > uitfile
FS is the fieldseperator to be replaced by 'n.
I tried it for multiple lines and works just fine.
Regards,
Ceesjan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-02-2002 07:49 AM
тАО04-02-2002 07:49 AM
Re: replacing /n with newline with ed.
sed 's,/n,,g' file-1 >file-2
This can be entered from command line or in a script. Note it really is 2 lines (the first ending with "\").
Darrell
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-02-2002 07:50 AM
тАО04-02-2002 07:50 AM
Re: replacing /n with newline with ed.
sed 's,/n,
,g' file-1 >file-2
Darrell
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-02-2002 07:53 AM
тАО04-02-2002 07:53 AM
Re: replacing /n with newline with ed.
Let's try it as an attachment.
Darrell