Replace end of line with a space


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Replace end of line with a space
# 1  
Old 03-21-2010
Replace end of line with a space

for eg:
i have i/p file as:
================
i
wnt
to
change end of line

=================
my require ouput is like:

i wnt to change end of line
====================
# 2  
Old 03-21-2010
Hi,
try the below :
tr '\r\n' ' ' old_file new_file

Regards,
# 3  
Old 03-21-2010
Code:
paste -sd' ' file

# 4  
Old 03-21-2010
Please re-post in Queens English without using any abbreviations, contractions or text-speak. Please show your input data, what data processing you expect, and what output you expect.
# 5  
Old 03-21-2010
its not working

above tr cmd not work and actually I need do it in vi editor

---------- Post updated at 01:14 AM ---------- Previous update was at 01:05 AM ----------

for example:
i have input file as:
===============
>cat file1
aa
bbbbb
ccccccccc

=================
my require ouput is likeSmiliein vi editor )
cat file1
aabbbbbccccccccc
====================
# 6  
Old 03-21-2010
Hello!

In case you forgot to read the forum rules, here iis #9.

Quote:
RULES OF THE UNIX AND LINUX FORUMS
[edit]

(9) Edit your posts if you see spelling or grammar errors (don't write in cyberchat or cyberpunk style). English only.
Cheers.

The UNIX and Linux Forums
# 7  
Old 03-21-2010
I am no vi expert, so there may be a way to do it without filtering through an external process. However, the following should do what you ask in just about any vi implementation:
Code:
:%!tr -d '\n'

In vim, the following works (but it fails in nvi):
Code:
:%s/\n//

Regards,
Alister
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

my shell now adds extra space at end of each line!

Hi, Since today, with csh or tcsh, if I do 'ls files* > list', every lines end with an extra space! What happenned? What can I do to go back when there was no extra space? If I change to bash, there's no extra space. Thanks, Patrick ---------- Post updated at 03:19 PM... (1 Reply)
Discussion started by: trogne
1 Replies

2. Shell Programming and Scripting

How to Add space at the end of each line in linux

hi,. I am writing a small script in csh... Can any one tel me how to add space at end of each line in a file (9 Replies)
Discussion started by: Manju87
9 Replies

3. Shell Programming and Scripting

Remove line starting from space till end.

Hi, I have a code tag, from which i have the below snippet: intelrpt.GetCMB_FB type=ODBC> intelrpt.GetCMB_FB type=SYBASE> I want the output like: intelrpt.GetCMB_FB intelrpt.GetCMB_FB That is remove the lines starting from WHITESPACE till end. Please help. I am new to... (7 Replies)
Discussion started by: anupdas
7 Replies

4. Shell Programming and Scripting

How to replace ^M present at the end of each line in a file.

Hi all, My unix admin copied my code from old server to new server. I don't know exactly how he copied by at the end of each line i see ^M appeneded. The code has more than 200 lines could you please help me how to remove it easilt instead of deleting it manually...... Thanks, Firestar. (6 Replies)
Discussion started by: firestar
6 Replies

5. Shell Programming and Scripting

NULL in between, at begining or at end of line - convert to space

How to replace null with space? I want to make each line with 80 characters. If any line contains only 5 characters and remaining is null, then i want to make it as 80 characrets where 5 is original characters and remaining 75 characters will be null.. NULL can come in between the line,... (3 Replies)
Discussion started by: Amit.Sagpariya
3 Replies

6. Shell Programming and Scripting

sed : replace space and end-of-line

Hi ! I'm rather new with sed ... learned a lot already by googling etc ... The following script should replace all spaces and ends-of-lines with "something (see below). #!/bin/bash i=0 while read line do fam="H`printf "%06d" $i`" echo $line | sed -e 's//\t'$fam'\n/g' i=$(($i+1))... (7 Replies)
Discussion started by: jossojjos
7 Replies

7. Shell Programming and Scripting

Add white space to the end of a line with sed

Im trying to add 5 blank spaces to the end of each line in a file in a sed script. I can figure out who o put the spaces pretty much anywhere else but at the end. thanks Karl (7 Replies)
Discussion started by: karlanderson
7 Replies

8. Shell Programming and Scripting

replace space with new line

i have a file named as templist which looks like this: i want to translate spaces to a new line so that the file would look like this im using sed with this sed -e 's/" "/\n/' templist > templist.out but it doesn't work. can someone please help me. (2 Replies)
Discussion started by: dakid
2 Replies

9. UNIX for Advanced & Expert Users

how can I read the space in the end of line

cat file1|while read i do echo "$i"|wc done with this command the space in the end of the line not considered how can solve that for example: read h "hgyr " echo "$h"|wc 4 (2 Replies)
Discussion started by: Ehab
2 Replies

10. Shell Programming and Scripting

to see space, tab, end of the line chracters

what can I use ?? In vi, I can use :set list <-- and see end of line $.. or use cat -A but I am wondering if there is command or program that allows me to see all the hidden characters( space, tab and etc) Please help thanks. (3 Replies)
Discussion started by: convenientstore
3 Replies
Login or Register to Ask a Question