Visit the LQ Articles and Editorials section
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


Search this Thread
Old 08-13-2012, 10:50 AM   #1
LQ Newbie
Registered: Aug 2012
Posts: 12

Rep: Reputation: Disabled
Need to replace '\n' with '\n~'

Need to replace '\n' with '\n~'

Old 08-13-2012, 11:09 AM   #2
Senior Member
Registered: Dec 2005
Location: Florida
Distribution: CentOS/Fedora
Posts: 2,555

Rep: Reputation: 463Reputation: 463Reputation: 463Reputation: 463Reputation: 463
are you wanting to automate this or are you editing a script?
Old 08-13-2012, 11:20 AM   #3
Registered: Jul 2009
Posts: 569

Rep: Reputation: 42
this sounds like homework...can you please show us what you did so far and we'll be happy to assist.
Old 08-13-2012, 11:29 AM   #4
Senior Member
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 2,961

Rep: Reputation: 1042Reputation: 1042Reputation: 1042Reputation: 1042Reputation: 1042Reputation: 1042Reputation: 1042Reputation: 1042
Your requirements and your example don't match. Putting the tilde after the newline would make it the first character on the second line, not the last character on the first line.

would become

Old 08-14-2012, 12:38 AM   #5
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 7,562

Rep: Reputation: 1939Reputation: 1939Reputation: 1939Reputation: 1939Reputation: 1939Reputation: 1939Reputation: 1939Reputation: 1939Reputation: 1939Reputation: 1939Reputation: 1939
+1 to suicidaleggroll
Old 08-14-2012, 06:49 AM   #6
David the H.
Bash Guru
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Debian sid + kde 3.5 & 4.4
Posts: 6,823

Rep: Reputation: 1948Reputation: 1948Reputation: 1948Reputation: 1948Reputation: 1948Reputation: 1948Reputation: 1948Reputation: 1948Reputation: 1948Reputation: 1948Reputation: 1948
As in most line editing, the usual tools are sed or awk. In this particular case sed is probably the better tool.

I'm not going to give you the solution, though. You should be able to figure it out yourself with a tiny bit of research.

Here are a few useful sed references:


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Sed replace Help replace for (<a> guessity Linux - Newbie 1 11-18-2011 09:05 AM
need to replace RH 9 ? juanb Linux - General 5 01-30-2004 08:32 PM
Replace HD CloudBuilder Linux - Hardware 1 11-03-2003 01:26 AM
problem in perl replace command with slash (/) in search/replace string ramesh_ps1 Red Hat 4 09-10-2003 01:04 AM
Is it possible to replace sh? J_Szucs *BSD 12 08-14-2002 10:50 PM

All times are GMT -5. The time now is 07:38 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration