Joining lines to single line in VI | Unix Linux Forums | UNIX for Dummies Questions & Answers

  Go Back    


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

Joining lines to single line in VI

UNIX for Dummies Questions & Answers


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 01-12-2006
bobo bobo is offline
Registered User
 
Join Date: Jan 2006
Last Activity: 5 March 2014, 10:47 AM EST
Posts: 158
Thanks: 0
Thanked 0 Times in 0 Posts
Network Joining lines to single line in VI

Dear friends,

In VI, I have these data shown below:

Line1
Line2
Line3
Line4

How can I JOIN these line to the first line? When I finished I should have:

Line1 Line2 Line3 Line4

is there a text length limit of how long a single line can be in VI?

Thank you much!
Sponsored Links
    #2  
Old 01-12-2006
blowtorch's Avatar
blowtorch blowtorch is offline Forum Advisor  
AFK
 
Join Date: Dec 2004
Last Activity: 28 July 2014, 9:39 AM EDT
Location: UK
Posts: 2,351
Thanks: 0
Thanked 6 Times in 6 Posts
You want to do this in vi right? Get to command mode in vi. Go to the line which should have the next line appended to it and then press shift-j (upper case j or J). This will append the next line at the end of the line that you currently are on.

eg. Your example will work as:

Code:
Line1[shift-j]     Line1 Line2[shift-j]     Line1 Line2 Line3
Line2          ->  Line3                  -> Line4                and so on... 
Line3               Line4 
Line4

Sponsored Links
    #3  
Old 01-12-2006
bobo bobo is offline
Registered User
 
Join Date: Jan 2006
Last Activity: 5 March 2014, 10:47 AM EST
Posts: 158
Thanks: 0
Thanked 0 Times in 0 Posts
Data

Is there a limit in the number of lines to be joined or limit of number of character in a single line?
    #4  
Old 01-12-2006
bobo bobo is offline
Registered User
 
Join Date: Jan 2006
Last Activity: 5 March 2014, 10:47 AM EST
Posts: 158
Thanks: 0
Thanked 0 Times in 0 Posts
Is there a short program that someone can help?

Many thanks!
Sponsored Links
    #5  
Old 01-12-2006
blowtorch's Avatar
blowtorch blowtorch is offline Forum Advisor  
AFK
 
Join Date: Dec 2004
Last Activity: 28 July 2014, 9:39 AM EDT
Location: UK
Posts: 2,351
Thanks: 0
Thanked 6 Times in 6 Posts
I did give you a reply. You haven't said whether that was any help or not. Also, you are violating the rules. In particular rule 4:
(4) Do not 'bump up' questions if they are not answered promptly. No duplicate or cross-posting and do not report a post where your goal is to get an answer more quickly.
Sponsored Links
    #6  
Old 01-12-2006
bobo bobo is offline
Registered User
 
Join Date: Jan 2006
Last Activity: 5 March 2014, 10:47 AM EST
Posts: 158
Thanks: 0
Thanked 0 Times in 0 Posts
Sorry! I did not mean to violate any rule!
Your post was helped! I am trying but each in my file are too long!

Thanks!
Sponsored Links
    #7  
Old 01-13-2006
Ygor's Avatar
Ygor Ygor is offline Forum Advisor  
Advisor
 
Join Date: Oct 2003
Last Activity: 10 November 2014, 6:18 PM EST
Location: 54.23, -4.53
Posts: 1,801
Thanks: 1
Thanked 112 Times in 98 Posts
You can do the whole file using...
Code:
paste -d ' ' -s file1 > file2

Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Joining multi-line output to a single line in a group gvk25 Shell Programming and Scripting 7 03-07-2012 06:22 AM
Multiple lines in a single column to be merged as a single line for a record Bhuvaneswari Shell Programming and Scripting 1 08-11-2011 04:16 AM
Joining contents in multiple lines to a single line Lucky Ali Shell Programming and Scripting 1 10-13-2010 10:51 PM
joining 2 lines into single one ali560045 Shell Programming and Scripting 3 10-16-2008 09:56 AM
Joining lines in reverse. append line 1 to line 2. dwalley Shell Programming and Scripting 7 08-04-2008 08:11 AM



All times are GMT -4. The time now is 04:23 AM.