Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Need to combine two lines in a file based on first character of each line in a file Post 302967631 by bakunin on Thursday 25th of February 2016 07:09:39 PM
Old 02-25-2016
You might find it easier to divide your problem into two separate problems which are solvable independently:

1) concatenate all lines not starting with a number to the last line starting with a number, separated by spaces.

2) replace the spaces in the last field with hyphens i.e. "word1 word2" -> "word1-word2".

What may help you is the fact that each line consists of four "fields", separated by comma. Is this only the case in your sample or is this so throughout your data?

Any efforts from your side?

I hope this helps.

bakunin
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Merging lines based on occurances of a particular character in a file

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... (2 Replies)
Discussion started by: mohan_tuty
2 Replies

2. Shell Programming and Scripting

join based on line number when one file is missing lines

I have a file that contains 87 lines, each with a set of coordinates (x & y). This file looks like: 1 200.3 -0.3 2 201.7 -0.32 ... 87 200.2 -0.314 I have another file which contains data that was taken at certain of these 87 positions. i.e.: 37 125 42 175 86 142 where the first... (1 Reply)
Discussion started by: jackiev
1 Replies

3. Shell Programming and Scripting

Combine multiple lines in file based on specific field

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 ... (8 Replies)
Discussion started by: ratheesh2011
8 Replies

4. Shell Programming and Scripting

Combine multiple unique lines from event log text file into one line, use PERL or AWK?

I can't decide if I should use AWK or PERL after pouring over these forums for hours today I decided I'd post something and see if I couldn't get some advice. I've got a text file full of hundreds of events in this format: Record Number : 1 Records in Seq : ... (3 Replies)
Discussion started by: Mayday22
3 Replies

5. Shell Programming and Scripting

Remove certain lines from file based on start of line except beginning and ending

Hi, I have multiple large files which consist of the below format: I am trying to write an awk or sed script to remove all occurrences of the 00 record except the first and remove all of the 80 records except the last one. Any help would be greatly appreciated. (10 Replies)
Discussion started by: nwalsh88
10 Replies

6. Shell Programming and Scripting

File w/ many line pairs--how do I order based on 1st lines only?

I have a file in which the data is stored in pairs of lines. The first line (beginining with ">") is a header, the second line is a sequence. I would like to sort the file by species name. Desired output for the example file: I can use sort -t'_' -k2 to alphabetize headers in the... (1 Reply)
Discussion started by: pathunkathunk
1 Replies

7. Shell Programming and Scripting

Joining lines in TXT file based on first character

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... (5 Replies)
Discussion started by: fuji_s
5 Replies

8. UNIX for Advanced & Expert Users

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,... (1 Reply)
Discussion started by: jayaP
1 Replies

9. Shell Programming and Scripting

Program to combine two lines in a file on checking the first character of each line

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,... (12 Replies)
Discussion started by: jayaP
12 Replies

10. UNIX for Beginners Questions & Answers

Reading a file line by line and print required lines based on pattern

Hi All, i want to write a shell script read below file line by line and want to exclude the lines which contains empty value for MOUNTPOINT field. i am using centos 7 Operating system. want to read below file. # cat /tmp/d5 NAME="/dev/sda" TYPE="disk" SIZE="60G" OWNER="root"... (4 Replies)
Discussion started by: balu1234
4 Replies
pydhcplib.strlist(3)						     PYDHCPLIB						      pydhcplib.strlist(3)

NAME
pydhcplib.strlist - Internal type of pydhcplib for lists of bytes processing. SYNOPSIS
from pydhcplib.type_hw_addr import hwmac a = strlist() a = strlist([100,100,10,42,44,26]) DESCRIPTION
The class pydhcplib.strlist is an specific type of pydhcplib. It exist in order to simplify processing of raw data from network. When a dhcp packet dhcp is received, it's a succession of approximately 300 bytes. Within pydhcplib these data are transformed in an intermediary form of type "strlist" in order to facilitate their handling. This intermediary form will eventually be suppressed in the stable versions of pydhcplib to speedup the processing time, but backward compatibility will be assured. The pydhcplib.strlist class creation argument can be a list of numbers whose value goes from 0?55. The pydhcplib.strlist class creation argument can be a string of ASCII character. METHODS
The implemented methods in this type are mostly comparison methods (= =, >, etc...) else : str() convert the address into a printable string type. list() convert the address into a list of bytes. EXAMPLES
Example program strlist_example.py : from pydhcplib.type_strlist import strlist word = strlist() word1 = strlist("azerty") word2 = strlist("qwerty") word3 = strlist([97, 122, 101, 114, 116, 121]) print "a0 : ",word print "a1 : ",word1 print "a2 : ",word2 print "a3 : ",word3 if word1 == word2 : print "test 1 : ",word1, "==",word2 else : print "test 1 : " ,word1, "!=",word2 if word1 == word3 : print "test 2 : ", word1, "==",word3 else : print "test 2 : ", word1, "!=",word3 SEE ALSO
pydhcp(8), pydhcplib.hwmac(3), pydhcplib.ipv4(3), pydhcplib.strlist(3), pydhcplib.DhcpPacket(3), pydhcplib.DhcpBasicPacket(3), pydhc- plib.DhcpNetwork(3), pydhcplib.DhcpClient(3), pydhcplib.DhcpRawClient(3), pydhcplib.DhcpDerver(3) BUGS
See http://pydhcplib.tuxfamily.org/ for more information. AUTHOR
Mathieu Ignacio (mignacio[AT]april.org) pydhcplib.strlist(3)
All times are GMT -4. The time now is 01:55 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy