Sponsored Content
Full Discussion: Combine incrimental line
Top Forums Shell Programming and Scripting Combine incrimental line Post 303005517 by pedot on Wednesday 18th of October 2017 10:09:09 PM
Old 10-18-2017
Quote:
Originally Posted by RudiC
Explaining heuristics (or a "plan to get from input to output") is not easy a task... First it helps a lot to know the ropes, i.e. what tools do you have at hand, their respective applicability, and what are the strengthes and weaknesses of each that might lean itself to the solution in this special, individual case. Here, awk stood out, but e.g. perl might fit even better - unfortunately, I don't have reasonable command of it.
Now, to the creative and - can I say - intuitive part, which can be a stepwise, repetitive, and approximating approach:
Check features and idiosyncrasies of the input, and what needs to be transported to the output. In this case, we can safely assume the input is sorted - should that not be the case, additional steps might need to be taken. We can identify two entities:


Code:
road[0] 100 300 500   \
road[1] 100 300 500    \  constant; go to road ... 100 300 500
road[2] 100 300 500    /  
road[3] 100 300 500   / 
     |
     +--> go to [0:3]

You see: $1 (which is field 1) needs to be split to get at its two elements that need different treatment. The constant part plus a placeholder plus the residual fields go to a working variable X, the numerical part is used to find MIN and MAX values, the latter in successive lines as we assume input is sorted. If the pattern in X changes, the output line is created from the LAST variable, by replacing the placeholder with the actual values, and printed out. At the end of each line's processing, X is saved in LAST.
Please bear in mind that above solution is taylored to the input sample given, so we stop here. Should additional conditions arise, they would need to be programmed in as well in - which may well happen - countless additional steps, conditional statements, loops, special cases, etc.

@RudiC
thanks a lot for such explanation / information..
i got overall general idea but need to understand more on deep level of awk maybe..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Combine reports and append a line between each

I am new to Unix and have tried to write a ksh script to do the following without success: I have several reports in a directory (report1, report2, report3, etc). I would like to combine all of these reports into one file (REPORTS). I would like to append *** End of Report *** to each report so... (2 Replies)
Discussion started by: ldevito1
2 Replies

2. Shell Programming and Scripting

Combine output on same line

I am trying to get some data from a file and print it on the same line. I have a script that gets the date/time and calculates a DB query call time and sends to a file. I need to take this file and send it in a xcel like format with multiple data columns. example output file (fndbq.out) ... (3 Replies)
Discussion started by: theninja
3 Replies

3. Shell Programming and Scripting

How to combine text data into one line?

The following input needs to be manipulated as follows: INPUT from file or results of command: ============start: Medium identifier : a45c0213:47eb5485:0aec:0321 Medium label : SQL Disk_11516 Location : Protected : None ... (2 Replies)
Discussion started by: rcky_mntere
2 Replies

4. UNIX for Dummies Questions & Answers

combine files line by line

Hi all, I once knew of a simple unix command to do this, but I can't remember it and I can't find it by searching. I have two files. ### FILE A #### A1 A2 A3 A4 A5 ### FILE B #### B1 B2 B3 B4 B5 (2 Replies)
Discussion started by: Digby
2 Replies

5. UNIX for Dummies Questions & Answers

What is the command use to combine line using sed

Hi all, What is the sed command use to combine line? Example: Below is an output after extracted from few commands aaa bbb ccc ddd eee fff ggg and i would like to combine all the line as shown below, aaa,bbb,ccc,ddd,eee,fff (5 Replies)
Discussion started by: 793589
5 Replies

6. Shell Programming and Scripting

Combine common line from 2 Huge files

Hi, I am having 2 huge files having line count more than 10million. The files look like: File 1 45905099 2059 942961505 3007 8450875165 7007 615565331 3015 9415586035 9012 9871573 5367 4415655 4011 44415539519 5361 3250659295 4001 5950718618 9367 File 2 44415539519 TQ03... (2 Replies)
Discussion started by: rochitsharma
2 Replies

7. Shell Programming and Scripting

Combine line before the pattern

Hi, I am not very familiar with sed and awk and i have a huge file to process which is impossible to do manually. I want to print out beginning from "Network" until end of line only (excluding the Version). AND. the decription to be all in one line. File: Version: 2.0 Network: xxx... (9 Replies)
Discussion started by: The One
9 Replies

8. Shell Programming and Scripting

Combine 2 line with space issue

Hello all, i am new to linux , and please need your help and suggestion on.... when vi 1.txt :set list, it looks like $ is displaying the end of line Filter: vlan1-BUM-1M $ BUM-1M 0 ... (4 Replies)
Discussion started by: samoptimus
4 Replies

9. Shell Programming and Scripting

Combine multiline to one line till a blank line

Hello, I have a file as :- ABC DEF GHI JKL <BlankLine> MNO PQR STU VWX <BlankLine> YZA I need it as below:- ABCDEFGHIJKL; MNOPQRSTUVWX; (3 Replies)
Discussion started by: jassi10781
3 Replies

10. Shell Programming and Scripting

awk to combine lines from line with pattern match to a line that ends in a pattern

I am trying to combine lines with these conditions: 1. First line starts with text of "libname VALUE db2 datasrc" where VALUE can be any text. 2. If condition1 is met then continue to combine lines through a line that ends with a semicolon. 3. Ignore case when matching patterns and remove any... (5 Replies)
Discussion started by: Wes Kem
5 Replies
g3tolj(1)						       mgetty+sendfax manual							 g3tolj(1)

NAME
g3tolj - converts a Group 3 fax file into a printable HP-PCL file SYNOPSIS
g3tolj [-kludge] [-reversebits] [-scale N] [-aspect N] [-resolution 75|100|150|300] [-compress 0|1|2] [-pagelength N] [-duplength N] [g3file] DESCRIPTION
Reads a Group 3 fax file (raw or digifax) as input. If no filename is given, stdin is used. Produces a printable HP-PCL file as output. OPTIONS
-kludge Tells g3tolj to skip the first lines for synchronisation. -reversebits Tells g3tolj to interpret bits least-significant first, instead of the default most-significant first. Apparently some fax modems do it one way and others do it the other way. If you get a whole bunch of "invalid code" messages, try using this flag. -scale N Scale the output to match the printer resolution and paper size, the default of 1.40 will do in most cases. -aspect N Scale the output to match the printer resolution and paper size, the default of 1.0 will do for high resolution faxes, 2.0 will do for low resolution faxes. -resolution 75|100|150|300 Selects print resolution. The default is 300. -compress 0|1|2 Selects compression method for the print output. 0 = none, 1 = rll, 2 = tiff. The default is 0. -pagelength N Defines the pagelength in inches, the default is 10.95. After this length a pagebreak is generated and the last part of the previous page is duplicated on the next page -duplength N Defines the length in inches that will be duplicated after a pagebreak, The default is 0.7. REFERENCES
The standard for Group 3 fax is defined in CCITT Recommendation T.4. BUGS
Please report bugs to chel@vangennip.nl SEE ALSO
pbmtog3(1), pbm(5), g3cat(1), sendfax(8), mgetty(1) AUTHOR
g3tolj is Copyright (C) 1994 by Chel van Gennip, <chel@vangennip.nl>. Sources of g3topbm and pbmtolj programs in Jef Poskanzers pbmplus package have been used, but al lot of code has been changed or added to simplify its use for printing faxes. Value added: low use of mem- ory, fast scaling, printing of long faxes with page breaks, print file compression (by John Watson) Chel 22 may 94 g3tolj(1)
All times are GMT -4. The time now is 03:57 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy