LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 04-19-2017, 04:29 AM   #1
moshebagelfresser
Member
 
Registered: Sep 2005
Location: Rishon Le Ziyyon Israel
Posts: 198

Rep: Reputation: 21
join text lines


Often I need to remove what is known as hard returns at the end of a line of text. The idea is join a line of text with the line above it.

I've not found an easy way to do this with a linux word processor, or text editor. Unfortunately, I have to use Textpad32 with Playonlinux. In Textpad32 selecting a paragraph then pressing Ctrl+Shift+J connects lines. Or to use Stripmail.

Does anyone know of a Linux programme that will do the job as easy instead of resorting to Windows programmes?

Last edited by moshebagelfresser; 04-19-2017 at 05:00 AM.
 
Old 04-19-2017, 04:40 AM   #2
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 19,713

Rep: Reputation: 3549Reputation: 3549Reputation: 3549Reputation: 3549Reputation: 3549Reputation: 3549Reputation: 3549Reputation: 3549Reputation: 3549Reputation: 3549Reputation: 3549
As always, there are a bunch of ways of doing this. As (almost) always, we have insufficient information to work with. Select lines only - all lines (entire document on one line), all of a paragraph, all paragraphs, or only a subset ... ?.

sed. awk, perl, no doubt python ... we can offer more with some representative data and the required output.
 
Old 04-19-2017, 04:45 AM   #3
moshebagelfresser
Member
 
Registered: Sep 2005
Location: Rishon Le Ziyyon Israel
Posts: 198

Original Poster
Rep: Reputation: 21
Lets say, I would like to join lines to appear as continuous line with wordwraping

the cat sat on the mat the cat sat on the mat the cat sat on the mat.

From
the cat sat on the mat
the cat sat on the mat
the cat sat on the mat.

Last edited by moshebagelfresser; 04-19-2017 at 05:03 AM.
 
Old 04-19-2017, 04:52 AM   #4
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 19,713

Rep: Reputation: 3549Reputation: 3549Reputation: 3549Reputation: 3549Reputation: 3549Reputation: 3549Reputation: 3549Reputation: 3549Reputation: 3549Reputation: 3549Reputation: 3549
I see nothing in your initial post to indicate change of case was required. paste will trivially handle that, but not the case change. Maybe lower-case the lot then fix the first character.
 
Old 04-19-2017, 06:21 AM   #5
moshebagelfresser
Member
 
Registered: Sep 2005
Location: Rishon Le Ziyyon Israel
Posts: 198

Original Poster
Rep: Reputation: 21
I have just installed a graphical Linux programme called Editra v0.7.20. In the Edit Menu, there is a Line Edit option Join Lines. If it works then this is just what I need.
 
Old 04-19-2017, 06:44 AM   #6
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 16,505

Rep: Reputation: 5548Reputation: 5548Reputation: 5548Reputation: 5548Reputation: 5548Reputation: 5548Reputation: 5548Reputation: 5548Reputation: 5548Reputation: 5548Reputation: 5548
in vi you only need to press J (shift-j) to join lines.
 
1 members found this post helpful.
Old 04-21-2017, 05:09 AM   #7
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 7.7 (?), Centos 8.1
Posts: 17,863

Rep: Reputation: 2598Reputation: 2598Reputation: 2598Reputation: 2598Reputation: 2598Reputation: 2598Reputation: 2598Reputation: 2598Reputation: 2598Reputation: 2598Reputation: 2598
... continuing with vi/vim
Code:
# all lines                                                                      
:%s/\n//

# or line range eg
:2,6s/\n//
 
  


Reply


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] Joining Three Lines of Text into One Line with Delimiters Between the Original Lines tronayne Slackware 25 03-18-2016 09:46 AM
Join two specific lines in a text file bfay General 2 03-02-2013 07:41 PM
[SOLVED] BASH: Reformatting text output to join lines inversecow Programming 4 01-18-2012 06:25 PM
Join lines in text file vidyashankara Linux - General 10 12-21-2009 03:17 PM
join every three lines of a text file powah Programming 8 02-01-2007 11:40 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 05:16 PM.

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