Unix/Linux Go Back    


UNIX for Advanced & Expert Users Expert-to-Expert. Learn advanced UNIX, UNIX commands, Linux, Operating Systems, System Administration, Programming, Shell, Shell Scripts, Solaris, Linux, HP-UX, AIX, OS X, BSD.

Need to combine two lines in a file based on first character of each line in a file

UNIX for Advanced & Expert Users


Closed    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 02-25-2016   -   Original Discussion by jayaP
jayaP jayaP is offline
Registered User
 
Join Date: Feb 2016
Last Activity: 12 May 2017, 7:43 AM EDT
Posts: 7
Thanks: 2
Thanked 0 Times in 0 Posts
Unix or Linux Question Need to combine two lines in a file based on first character of each line in a file

Hi,

I have a requirement where I need to combine two lines in a file based on first character of each line in a file.

Please find the sample content of the file below:

Code:
_______________________
5, jaya, male, 4-5-90, single
smart
6, prakash, male, 5-4-84, married
fair
7, raghavi, female, 12-10-85, married
calm
talented
9, bhaskar, male, 29-12-92, single
studios
________________________

I want the output for this file as
_______________________

Code:
5, jaya, male, 4-5-90, single-smart
6, prakash, male, 5-4-84, married-fair
7, raghavi, female, 12-10-85, married-calm-talented
9, bhaskar, male, 29-12-92, single-studios

________________________

can you please help me with the shell program that achieve my requirement?
Sponsored Links
    #2  
Old Unix and Linux 02-25-2016   -   Original Discussion by jayaP
Don Cragun's Unix or Linux Image
Don Cragun Don Cragun is offline Forum Staff  
Administrator
 
Join Date: Jul 2012
Last Activity: 20 November 2017, 12:28 AM EST
Location: San Jose, CA, USA
Posts: 10,661
Thanks: 572
Thanked 3,734 Times in 3,186 Posts
Moderator's Comments:
Need to combine two lines in a file based on first character of each line in a file This appears to be a duplicate of the thread: Need to combine two lines in a file based on first character of each line in a file. Continue any discussion on this topic there.

This thread is closed.
Sponsored Links
Closed

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Program to combine two lines in a file on checking the first character of each line jayaP Shell Programming and Scripting 12 02-26-2016 11:03 AM
Joining lines in TXT file based on first character fuji_s Shell Programming and Scripting 5 08-20-2013 04:19 AM
Combine multiple unique lines from event log text file into one line, use PERL or AWK? Mayday22 Shell Programming and Scripting 3 11-06-2012 09:00 PM
Combine multiple lines in file based on specific field ratheesh2011 Shell Programming and Scripting 8 07-11-2012 03:39 PM
Merging lines based on occurances of a particular character in a file mohan_tuty Shell Programming and Scripting 2 07-15-2008 02:14 AM



All times are GMT -4. The time now is 11:38 AM.