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


Login or Register to Reply

 
Thread Tools Search this Thread
# 1  
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?
# 2  
Moderator's Comments:
Mod Comment 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.
Login or Register to Reply

|
Thread Tools Search this Thread
Search this Thread:
Advanced Search

More UNIX and Linux Forum Topics You Might Find Helpful
Program to combine two lines in a file on checking the first character of each line
jayaP
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: _______________________ 5, jaya, male, 4-5-90, single smart 6, prakash, male, 5-4-84, married fair 7, raghavi, female,...... Shell Programming and Scripting
12
Shell Programming and Scripting
Need to combine two lines in a file based on first character of each line in a file
jayaP
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,...... UNIX for Dummies Questions & Answers
1
UNIX for Dummies Questions & Answers
Joining lines in TXT file based on first character
fuji_s
Hi, I have a pipe delimeted text file where lines have been split over 2 lines and I need to join them back together. For example the file I have is similar to the following: aaa|bbb |ccc ddd|eee fff|ggg |hhh I ideally need to have it looking like the following aaa|bbb|ccc ddd|eee...... Shell Programming and Scripting
5
Shell Programming and Scripting
Combine multiple lines in file based on specific field
ratheesh2011
Hi, I have an issue to combine multiple lines of a file. I have records as below. Fields are delimited by TAB. Each lines are ending with a new line char (\n) Input -------- ABC 123456 abcde 987 890456 7890 xyz ght gtuv ABC 5tyin 1234 789 ghty kuio ABC ghty jind 1234 678 ght ...... Shell Programming and Scripting
8
Shell Programming and Scripting
Merging lines based on occurances of a particular character in a file
mohan_tuty
Hi, Is there any way to merge two lines based on specific occurance of a character in a file. I am having a flat file which contains multiple records. Each row in the file should contain specified number of delimiter. For a particular row , if the delimiter count is not matched with...... Shell Programming and Scripting
2
Shell Programming and Scripting