Sponsored Content
Top Forums Shell Programming and Scripting Merging lines - Tuning the script Post 302172833 by senthil_is on Tuesday 4th of March 2008 08:45:14 PM
Old 03-04-2008
The example of the file format is i am using # for comment

101 10000217311 # Header always starts with 1
5200Paydonee 11 # Batch always Header Stats with 5
622100002173011 # Data always starts with 6
705CTB 4 0112 # If lin strts with 7, it has to be merged with previous line. and also the batch header counter has to be padded at end of line.
705Pymt Ref 4991
622100002173066
705CTB 19 5622
705532119P 386
622100002173011
705CTB 20 338
705 44888
822000000112998 # batch trailer always starts with 8
900001100021000 # Trailer of the file always starts with 9


Lines start with 7 has to be merged with the previous lines start with 6 and the line length should be 605.

Last edited by senthil_is; 03-04-2008 at 09:48 PM.. Reason: adding some more
 

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
BATCHER(8)						      System Manager's Manual							BATCHER(8)

NAME
batcher - article batching backend for InterNetNews SYNOPSIS
batcher [ -a arts ] [ -A total_arts ] [ -b size ] [ -B total_size ] [ -i string ] [ -N num_batches ] [ -p process ] [ -r ] [ -s separator ] [ -S alt_spool ] [ -v ] host [ input ] DESCRIPTION
Batcher reads uses a list of files to prepare news batches for the specified host. It is normally invoked by a script run out of cron(8) that uses shlock(1) to lock the host name, followed by a ctlinnd(8) command to flush the batchfile. Batcher reads the named input file, or standard input if no file is given. Relative pathnames are interpreted from the /var/spool/news/out.going directory. The input is taken as a set of lines. Blank lines and lines starting with a number sign (``#'') are ignored. All other lines should consist of one or two fields separated by a single space. The first field is the name of a file holding an article; if it is not an an absolute pathname it is taken relative to the news spool directory, /var/spool/news. The second field, if present, specifies the size of the article in bytes. OPTIONS
-S The ``-S'' flag may be used to specify an alternate spool directory to use if the article is not found; this would normally be an NFS-mounted spool directory of a master server with longer expiration times. -r By default, the program sets its standard error to /var/log/news/errlog. To suppress this redirection, use the ``-r'' flag. -v Upon exit, batcher reports statistics via syslog(3). If the ``-v'' flag is used, they will also be printed on the standard output. -b Batcher collects the text of the named articles into batches. To limit the size of each batch, use the ``-b'' flag. The default size is 60 kilobytes. Using ``-b0'' allows unlimited batch sizes. -a To limit the number of articles in each batch, use the ``-a'' flag. The default is no limit. A new batch will be started when either the byte count or number of articles written exceeds the specified limits. -B To limit the total number of bytes written for all batches, use the ``-B'' flag. -A To limit the total number of articles that can be batched use the ``-A'' flag. -N To limit the total number of batches that should be created use the ``-N'' flag. In all three cases, the default is zero, which is taken to mean no limit. -i string A batch starts with an identifying line to specify the unpacking method to be used on the receiving end. When the ``-i'' flag is used, the initial string, string, followed by a newline, will be output at the start of every batch. The default is to have no ini- tial string. -s Each article starts with a separator line to indicate the size of the article. To specify the separator use the ``-s'' flag. This is a sprintf(3) format string which can have a single ``%ld'' parameter which will be given the size of the article. If the separa- tor is not empty, then the string and a newline will be output before every article. The default separator is ``#! rnews %ld''. -p By default, batches are written to standard output, which is not useful when more than one output batch is created. Use the ``-p'' flag to specify the shell command that should be created (via popen(3)) whenever a new batch is started. The process is a sprintf format string which can have a single ``%s'' parameter which will be given the host name. A common value is: ( echo '#! cunbatch' ; exec compress ) | uux - -r -z %s!rnews EXIT STATUS
If the input is exhausted, batcher will exit with a zero status. If any of the limits specified with the ``-B,'' ``-A,'' or ``-N'' flags is reached, or if there is an error writing the batch, then batcher will try to spool the input, copying it to a file. If there was no input filename, the standard input will be copied to /var/spool/news/out.going/host and the program will exit. If an input filename was given, a temporary file named input.bch (if input is an absolute pathname) or /var/spool/news/out.going/input.bch (if the filename does not begin with a slash) is created. Once the input is copied, batcher will try to rename this temporary file to be the name of the input file, and then exit. Upon receipt of an interrupt or termination signal, batcher will finish sending the current article, close the batch, and then rewrite the batchfile according as described in the previous paragraph. HISTORY
Written by Rich $alz <rsalz@uunet.uu.net> for InterNetNews. This is revision 1.18, dated 1996/10/29. SEE ALSO
ctlinnd(8), newsfeeds(5), shlock(1). BATCHER(8)
All times are GMT -4. The time now is 10:33 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy