Sponsored Content
Top Forums Shell Programming and Scripting Merging lines - Tuning the script Post 302172865 by senthil_is on Wednesday 5th of March 2008 02:24:08 AM
Old 03-05-2008
Thank you very much summer_cherry. Thanks for another awk reply also.

My requirement is :

i have file which has the following format

header
BatchHeader-1
Details1
700000023
Details2
75858585
72323232
BatchTrailer-1
BatchHeader-2
Details1
700000023
Details2
75858585
72323232
BatchTrailer-2
Trailer

I want the output like below.

header
BatchHeader-1
Details1700000023 1 # this 1 means that detail belongs to batchheader-1
Details27585858572323232 1
BatchTrailer-1
BatchHeader-2
Details1700000023 2 # this 2 means that detail belongs to batchheader-2
Details27585858572323232 2
BatchTrailer-2
Trailer
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Merging lines into one

Hello. I would be very pleased if sb. help me to solve my problem. I've got a file with many non blank lines and I want to merge all lines into one not destroy the informations on them. I've tryed it with split and paste, tr, sed , but everything I've done has been wrong. I know about crazy... (8 Replies)
Discussion started by: Foxgard
8 Replies

2. Web Development

MySQL Tuning Tools with mysqltuner.pl and tuning-primer.sh

We have been tuning MySQL lately and I ran accoss two useful tools that you might be interested in: mysqltuner.pl tuning-primer.sh Both of these scripts are quite useful for MySQL tuning. Here is some sample output of mysqltuner.pl >> MySQLTuner 0.9.8 - Major Hayden... (3 Replies)
Discussion started by: Neo
3 Replies

3. Shell Programming and Scripting

Shell script for merging lines in a loop

Dear All, I need a script to merge lines of an input file in a loop, please guide me for the script or one liner(awk, sed, tr, shell, perl). I/P File------------------------- APaul,,,,SDH,,23,,,PPH,,2 ,,,,KKH,,19,,,MMH,,12, ,,,,CCH,,22,,,MNH,,19, ,,,,TCH,,55,,,NNH,,67,... (3 Replies)
Discussion started by: ashis.tewari
3 Replies

4. Shell Programming and Scripting

Merging lines

Hi folks. Could somebody help me write a script or command that will look through a file and for every line that doesn't contain a certain value, merge it with the one above? For example, the file contains: SCOTLAND|123|ABC|yes SCOTLAND|456|DEF|yes SCOTLAND|78 9|GHI|yes ... (3 Replies)
Discussion started by: MDM
3 Replies

5. Shell Programming and Scripting

merging two .txt files by alternating x lines from file 1 and y lines from file2

Hi everyone, I have two files (A and B) and want to combine them to one by always taking 10 rows from file A and subsequently 6 lines from file B. This process shall be repeated 40 times (file A = 400 lines; file B = 240 lines). Does anybody have an idea how to do that using perl, awk or sed?... (6 Replies)
Discussion started by: ink_LE
6 Replies

6. Shell Programming and Scripting

Merging lines

Thanks it worked for me. I have one more question on top of that. We had few records which were splitted in 2 lines instead of one. Now i identified those lines. The file is too big to open via vi and edit it. How can i do it without opening the file. Suppose, I want line number 1001 & 1002 to... (2 Replies)
Discussion started by: Gangadhar Reddy
2 Replies

7. Shell Programming and Scripting

Merging 2 lines together

I have a small problem, which due to my lack of knowledge, has left me unable to decipher some of the solutions that I looked at on these forums. So below is a piece of text, which I ran via cat -vet, which comes from within a program file. I have many such programs to process and repeatable,... (4 Replies)
Discussion started by: skarnm
4 Replies

8. Shell Programming and Scripting

Merging the lines of a file

Hello, I have a file with few lines starting with a digit (1-5 only ) followed by a dot (.). Remaining all the lines to be merged with its previous numbered lines. Merging must be done with a space. E.g., Source file: 3. abc def xyz 5. pqr mno def 4. jkl uvw 7. ghi 1. abc xyz 6. mno... (4 Replies)
Discussion started by: magnus29
4 Replies

9. Shell Programming and Scripting

Merging multiple lines to columns with awk, while inserting commas for missing lines

Hello all, I have a large csv file where there are four types of rows I need to merge into one row per person, where there is a column for each possible code / type of row, even if that code/row isn't there for that person. In the csv, a person may be listed from one to four times... (9 Replies)
Discussion started by: RalphNY
9 Replies

10. UNIX for Beginners Questions & Answers

Merging two lines into one (awk)

Hi, I am attempting to merge the following lines which run over two lines using awk. INITIAL OUTPUT 2019 Sep 28 10:47:24.695 hkaet9612 last message repeated 1 time 2019 Sep 28 10:47:24.695 hkaet9612 %ETHPORT-5-IF_DOWN_INTERFACE_REMOVED: Interfa ce Ethernet1/45 is down (Interface removed)... (10 Replies)
Discussion started by: sand1234
10 Replies
et_selector(3erl)					     Erlang Module Definition						 et_selector(3erl)

NAME
et_selector - Define event transforms and trace patterns DESCRIPTION
EXPORTS
make_pattern(RawPattern) -> TracePattern Types RawPattern = detail_level() TracePattern = erlang_trace_pattern_match_spec() detail_level() = min | max | integer(X) when X >= 0, X =< 100 Makes a trace pattern suitable to feed change_pattern/1 Min detail level deactivates tracing of calls to et:trace_me/4,5 Max detail level activates tracing of all calls to et:trace_me/4,5 integer(X) detail level activates tracing of all calls to et:trace_me/4,5 whose detail level argument is lesser than X. See also erlang:trace_pattern/2 for more info about its match_spec() change_pattern(Pattern) -> ok Types Pattern = detail_level() | empty_match_spec() | erlang_trace_pattern_match_spec() detail_level() = min | max | integer(X) when X >= 0, X =< 100 empty_match_spec() = [] Activates/deactivates tracing by changing the current trace pattern. min detail level deactivates tracing of calls to et:trace_me/4,5 max detail level activates tracing of all calls to et:trace_me/4,5 integer(X) detail level activates tracing of all calls to et:trace_me/4,5 whose detail level argument is lesser than X . An empty match spec deactivates tracing of calls to et:trace_me/4,5 Other match specs activates tracing of calls to et:trace_me/4,5 accordingly with erlang:trace_pattern/2 . parse_event(Mod, ValidTraceData) -> false | true | {true, Event} Types Mod = module_name() | undefined <v>module_name() = atom() <v>ValidTraceData = erlang_trace_data() | record(event) erlang_trace_data() = {trace, Pid, Label, Info} | {trace, Pid, Label, Info, Extra} | {trace_ts, Pid, Label, Info, ReportedTS} | {trace_ts, Pid, Label, Info, Extra, ReportedTS} | {seq_trace, Label, Info} | {seq_trace, Label, Info, ReportedTS} | {drop, NumberOfDroppedItems} Transforms trace data and makes an event record out of it. See erlang:trace/3 for more info about the semantics of the trace data. An event record consists of the following fields: detail_level : Noise has a high level as opposed to essentials. trace_ts : Time when the trace was generated. Same as event_ts if omitted in trace data. event_ts : Time when the event record was created. from : From actor, such as sender of a message. to : To actor, such as receiver of message. label : Label intended to provide a brief event summary. contents : All nitty gritty details of the event. See et:trace_me/4 and et:trace_me/5 for details. Returns: {true, Event} : where Event is an #event{} record representing the trace data true : means that the trace data already is an event record and that it is valid as it is. No transformation is needed. false : means that the trace data is uninteresting and should be dropped Ericsson AB et 1.4.2 et_selector(3erl)
All times are GMT -4. The time now is 01:30 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy