How to replace newline "\n"


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers How to replace newline "\n"
# 1  
Old 06-06-2001
How to replace newline "\n"

How do I replace the newline character in "vi" editor.

I want to replace the string " \n" (ie, Blank followed by NewLine) with " " . How do I do this?

I want to try this from vi editor and then using "sed".


Thanks,
# 2  
Old 06-07-2001
If you want to marge rows ( for exp. row 1 to 20 ) do:
:1,20 j
yairon
# 3  
Old 06-07-2001

tr "\n" " " < filename


# 4  
Old 06-07-2001
But, I want to replace the newline character only if it is followed by a blank space.

ie, I wan to replace "blankspace\n" with "blankspace" and dont want to replace (say, ";\n")

Thank u verymuch for your response
# 5  
Old 06-09-2001
NewLine

What i interpreted from your question is that you have a file in which the text is somewhat as shown

\n
sdsdjfsjnfj \n asdmkasmdkamdk \n
sdmfksdmfksd \n
\n
masdkak \n
\n

and now you want to replace the " \n" with ""
so you can try the search and replace command i.e
:%s/ \\n//g
I tried this on solaris and it worked fine.

Smilie
# 6  
Old 06-09-2001
It didn't work on Linux.

Note where "\n" is new line. It seems u are taking "\n" as a string of "\" and character "n".

Thanks,
 
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Bash script - Print an ascii file using specific font "Latin Modern Mono 12" "regular" "9"

Hello. System : opensuse leap 42.3 I have a bash script that build a text file. I would like the last command doing : print_cmd -o page-left=43 -o page-right=22 -o page-top=28 -o page-bottom=43 -o font=LatinModernMono12:regular:9 some_file.txt where : print_cmd ::= some printing... (1 Reply)
Discussion started by: jcdole
1 Replies

2. UNIX for Advanced & Expert Users

How newline character "^M" appeared in file?

I have two files. Diff and hexdump tell that they are identical. However vi shows windows newline characters "^M" in one of these files. How is this possible? (2 Replies)
Discussion started by: urello
2 Replies

3. UNIX for Dummies Questions & Answers

Using "mailx" command to read "to" and "cc" email addreses from input file

How to use "mailx" command to do e-mail reading the input file containing email address, where column 1 has name and column 2 containing “To” e-mail address and column 3 contains “cc” e-mail address to include with same email. Sample input file, email.txt Below is an sample code where... (2 Replies)
Discussion started by: asjaiswal
2 Replies

4. UNIX for Dummies Questions & Answers

replace "," with "." only in specific columns of a file?

Hi all, I have this text file containing 9 columns separated by space. The 8th columns contains the numbers. C1 C2 C3 C4 C5 C6 C7 C8 C9 er rt yt gh iu nk il 0.07 xs yt lr ty bg iu zk nh 0,0005 lt ...etc. I want to replace the comma with full stop only in 8th coloumn. the output... (8 Replies)
Discussion started by: Unilearn
8 Replies

5. Shell Programming and Scripting

awk command to replace ";" with "|" and ""|" at diferent places in line of file

Hi, I have line in input file as below: 3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL My expected output for line in the file must be : "1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL" Can someone... (7 Replies)
Discussion started by: shis100
7 Replies

6. Shell Programming and Scripting

Very Simple "Tabs to Newline" Code???

hi people; i have a text, iptables.txt and values are as follows inside: (seperators are TAB) 10.15.2.2 2 40 10.15.3.3 1 10 10.32.2.1 3 40 10.33.6.7 2 50 10.16.3.2 1 60 10.11.3.9 1 20 10.19.2.1 1 80 10.16.9.9 3 20 10.29.7.9 2 90 10.33.2.7 3 40 ...... i... (5 Replies)
Discussion started by: gc_sw
5 Replies

7. Shell Programming and Scripting

How to replace "®" "™" "with Spaces in UNIX

do U know how to replace the registered trademark "®" symbol or trade Mark "™" "with Spaces in UNIX (4 Replies)
Discussion started by: MMeari
4 Replies

8. UNIX for Dummies Questions & Answers

Match newline character "\n" in lex

Hi everyone! This is my very first post, sorry if I'm not posting in the right category. I'm trying to match a newline "/n" using lex/yacc. For example, print(9,'\n',8) should print 9 8 now do I write a regular expression to match exactly " '\n' " Thanks! (1 Reply)
Discussion started by: code21
1 Replies

9. Shell Programming and Scripting

deleting newline characters but not the "true" \n character

hi, i have a file that has about 4500 rows. this was an old microsoft access databse and what i am trying to do is take out the old extra \n newline characters but not take out the "true" newline character. I will explain. i was trying to write a regular expression, but that was not... (1 Reply)
Discussion started by: caddyjoe77
1 Replies
Login or Register to Ask a Question