Sponsored Content
Top Forums Shell Programming and Scripting Splitting record into multiple records by appending values from an input field (AWK) Post 302628845 by birei on Tuesday 24th of April 2012 04:40:39 AM
Old 04-24-2012
Hi imtiaz99,

Try with perl. It's a great tool for this kind of tasks:
Code:
$ cat infile
11686 19151 25489 45012
11686 19151 3257 29286 3209|6774|8928|20459|37185
11686 19151 39792 21367 38922 65000
11686 19151 9002 31200 41654|64999|65000|65002|65011|65012|65014|65100|65200|65500
$ perl -lane '
    if ( index( $F[ $#F ], q[|] ) > -1 ) { 
        @f = split /\|/, $F[ $#F ]; 
        for ( @f ) { 
            printf qq[%s %s\n], qq{@F[0..(@F-2)]}, $_ 
        } 
    } 
    else { 
        printf qq[%s\n], $_ 
    }
' infile
11686 19151 25489 45012
11686 19151 3257 29286 3209
11686 19151 3257 29286 6774
11686 19151 3257 29286 8928
11686 19151 3257 29286 20459
11686 19151 3257 29286 37185
11686 19151 39792 21367 38922 65000
11686 19151 9002 31200 41654
11686 19151 9002 31200 64999
11686 19151 9002 31200 65000
11686 19151 9002 31200 65002
11686 19151 9002 31200 65011
11686 19151 9002 31200 65012
11686 19151 9002 31200 65014
11686 19151 9002 31200 65100
11686 19151 9002 31200 65200
11686 19151 9002 31200 65500

This User Gave Thanks to birei For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Multiple input field Separators in awk.

I saw a couple of posts here referencing how to handle more than one input field separator in awk. I figured I would share how I (just!) figured out how to turn this line in a logfile: 90000000000000000000010001 name... (4 Replies)
Discussion started by: kinksville
4 Replies

2. Shell Programming and Scripting

Splitting input files into multiple files through AWK command

Hi, I needs to split *.txt files from single directory depends on the some mutltiple input values. i have wrote the code like below for file in *.txt do grep -i -h "value1|value2" $file > $file; done. My requirment is more input values needs to be given in grep; let us say 50... (3 Replies)
Discussion started by: arund_01
3 Replies

3. Shell Programming and Scripting

awk - splitting 1 large file into multiple based on same key records

Hello gurus, I am new to "awk" and trying to break a large file having 4 million records into several output files each having half million but at the same time I want to keep the similar key records in the same output file, not to exist accross the files. e.g. my data is like: Row_Num,... (6 Replies)
Discussion started by: kam66
6 Replies

4. Shell Programming and Scripting

awk + gsub to search multiple input values & replace with located string + extra text

Hi all. I have the following command that is successfully searching for any one of the strings on all lines of a file and replacing it with the instructed value. cat inputFile | awk '{gsub(/aaa|bbb|ccc|ddd/,"1234")}1' > outputFile This does in fact replace any occurrence of aaa, bbb,... (2 Replies)
Discussion started by: dazhoop
2 Replies

5. Shell Programming and Scripting

SED/AWK to edit/add field values in a record

Hi Experts, I am new to shell scripting. Need some help in doing one task given by the customer. The sample record in a file is as follows: 3538,,,,,,ID,ID1,,,,,,,,,,, It needs to be the following: 3538,,353800,353800,,,ID,ID1,,,,,COLX,,,,,COLY, And i want to modify this record in... (3 Replies)
Discussion started by: sugarcane
3 Replies

6. Shell Programming and Scripting

Multiple Records from 1 Record

I need to make one record to multiple records based on occurence column in the record and change the date.For example below first record has 5 ,so need to create 5 records from one and change the date to 5 months.Occurence can be any number. I am unable to come with a script.Can some one help ... (5 Replies)
Discussion started by: traininfa
5 Replies

7. Shell Programming and Scripting

Read record from the text file contain multiple separated values & assign those values to variables

I have a file containing multiple values, some of them are pipe separated which are to be read as separate values and some of them are single value all are these need to store in variables. I need to read this file which is an input to my script Config.txt file name, first path, second... (7 Replies)
Discussion started by: ketanraut
7 Replies

8. Shell Programming and Scripting

Insert field values in a record using awk command

Hi Friends, Below is my input file with "|" (pipe) as filed delimiter: My Input File: HDR|F1|F2||||F6|F7 I want to inser values in the record for field 4 and field 5. Expected output HDR|F1|F2||F4|F5|F6|F7 I am able to append the string to the end of the record, but not in between the... (3 Replies)
Discussion started by: Ajay Venkatesan
3 Replies

9. UNIX for Beginners Questions & Answers

awk GSUB read field values from multiple text files

My program run without error. The problem I am having. The program isn't outputting field values with the column headers to file.txt. Each of the column headers in file.txt has no data. MEMSIZE SECOND SASFoundation Filename The output results in file.txt should show: ... (1 Reply)
Discussion started by: dellanicholson
1 Replies

10. Shell Programming and Scripting

Script for splitting file of records into multiple files

Hello I have a file of following format HDR 1234 abc qwerty abc def ghi jkl HDR 4567 xyz qwerty abc def ghi jkl HDR 890 mno qwerty abc def ghi jkl HDR 1234 abc qwerty abc def ghi jkl HDR 1234 abc qwerty abc def ghi jkl -Need to split this into multiple files based on tag... (8 Replies)
Discussion started by: wincrazy
8 Replies
SENDQ(5)							File Formats Manual							  SENDQ(5)

NAME
sendq/q* - HylaFAX outbound job description DESCRIPTION
Files in the sendq directory specify transmission job requests. These files are created by hfaxd(8), when submitting a job on behalf of sendfax(1) or sendpage(1). Job description files also reside in the doneq directory; they are moved there by faxq(8) when a job completes. Job description files are ASCII files with lines of the form tag: value where a tag is one of the identifiers described below and a value is either a string or number. Values start at the first non-blank char- acter after the ``:'' and continue to the end of the line. Lines that end with a backslash character ``'' are continued to the next line. Numeric values are decimal integers, except for chophreshold which is expressed as a floating point value. The following table lists the possible tags and the required type of the associated value. Tag Type Description chopthreshold float page chopping threshold (inches) commid string communication identifier for last call company string receiver's company client string host that submitted the job cover string continuation coverpage file data string unprocessed document of indeterminate type !data string processed document of indeterminate type dataformat string data format used to transmit a facsimile desiredbr integer desired maximum transmit speed desireddf integer desired page data format desiredec integer desired use of Error Correction Mode (ECM) desiredst integer desired minimum scanline time desiredtl integer whether or not to use tagline parameter doneop string operation to perform when job is reaped errorcode string job status error code external string external form of dialstring fax string document ready for transmission faxnumber string faxnumber to use sending groupid integer HylaFAX job group identifier jobid integer HylaFAX job identifier jobtag string user-specified job identifier jobtype string job type identification string killtime integer time to give up trying to send job location string receiver's location mailaddr string email address of sender maxdials integer max number of times to dial maxtries integer max number of attempts to send job minbr integer minimum required transmit speed modem string outgoing modem to use ndials integer number of consecutive failed attempts to place call notify string email notification specification npages integer number of pages transmitted ntries integer number of attempts to send current page number string dialstring to use in placing call owner string user that owns the job page string PIN in a page operation pagechop string whitespace truncation handling pagehandling string page analysis information pagelength integer facsimile page length (millimeters) pagewidth integer facsimile page width (millimeters) passwd string info to send in HDLC PWD frame pcl string unprocessed PCL document !pcl string processed PCL document poll string polling request postscript string unprocessed POSTSCRIPT document !postscript string processed POSTSCRIPT document priority integer user-specified scheduling priority receiver string receiver's identity resolution integer vertical resolution of facsimile retrytime integer time to use between job retries returned integer indicates return status value for the job schedpri integer current scheduling priority sender string identity of sender signalrate string signalling rate at which a facsimile was sent state integer job scheduling state status string job status subaddr string info to send in HDLC SUB frame tagline string tagline format string tiff string unprocessed TIFF/F document !tiff string processed TIFF/F document totdials integer total number of phone calls totpages integer total pages to transmit tottries integer total number of attempts to send job tsi string TSI to transmit when sending tts integer time to send job useccover integer whether or not to use a continuation cover page usexvres integer whether or not to use highest vertical resolution PARAMETERS
Note that all files must be owned by the fax user. Pathnames for document files must be relative to the top of the HylaFAX spooling direc- tory and not include ``..''. chopthreshold The minimum trailing whitespace (in inches) that must appear on a page for it to be considered for ``page chopping''. If this parameter is not specified then the value specified by the PageChopThreshold configuration parameter is used; see hylafax-config(5). commid The communication identifier for the last outbound call placed for this job. This string is of the form ``XXXXXXXX'' where XXXXXXXX is a decimal sequence number in the range 1-99999999. client The fully qualified hostname for the machine from which the job was submitted. If the hostname is unknown at the time the job is submitted, then the host address in Internet standard ``.'' (dot) notation is supplied instead. company The receiver's company name as specified with the -x option to sendfax(1). This value is used only when creating continua- tion cover pages. cover The pathname of a continuation cover page to send. The file must be TIFF/F (i.e. it must already be prepared for transmis- sion). This document will be transmitted before any other documents listed in the file. See ContCoverPage and ContCoverCmd in hylafax-config(5). data The pathname of a document to send. Once a document has been processed, it is marked as !data so that subsequent retries do not reprocess the document. dataformat The format used to transmit facsimile data. This item is recorded by faxsend(8) so that notify(8) can return it in a notifi- cation message. desiredbr The desired signalling rate to use for page data transmissions: 0 for 2400 bps, 1 for 4800 bps, 2 for 7200 bps, 3 for 9600 bps, 4 for 12000 bps, 5 for 14400 bps, 6 for 16800 bps, 7 for 19200 bps, 8 for 21600 bps, 9 for 24000 bps, 10 for 26400 bps, 11 for 28800 bps, 12 for 31200 bps, and 13 for 33600 bps (default). desireddf The desired data format to use for page data transmissions: 0 for 1-D MH, 1 for 2-D MR, 3 for 2-D MR with uncompressed data, and 4 for 2-D MMR (default). desiredec Which type of Error Correction Mode (ECM) to use: 0 to disable, 1 for 64-byte ECM, 2 for 256-byte ECM (default). desiredst The desired minimum scanline time to use for page data transmissions: 0 for 0 ms (default), 1 for 5 ms, 2 for 10ms/5ms, 3 for 10ms, 4 for 20ms/10ms, 5 for 20ms, 6 for 40ms/20ms, and 7 for 40ms. This value is used in selecting the negotiated session parameters. desiredtl Whether or not to use the format string specified by the tagline job parameter when imaging taglines on document pages. If this value is non-zero then per-job format string is used; otherwise the tagline format string specified in the server con- figuration file is used; see TagLineFormat in hylafax-config(5). doneop The treatment the job should be given when it is processed by the faxqclean(8) job cleaner program. The may be one of remove (to expunge the job description file and all associated documents that are not referenced by another job) or archive (to request that the job and associated documents be archived on the server machine). Consult faxqclean more details on other information that may be included in this string. errorcode The codified form of the status message intended for use by clients which provide customized status messages keyed from this standard index. external The external form of the dialstring. This string is used instead of the dialstring in any status and log messages. Clients can protect private information such as access codes that must be placed in dialstrings by supplying a ``cleansed'' version of the dialstring. fax The pathname of a TIFF/F document that is ready for transmission. If the pathname string has a leading ``xx:'', then ``xx'' is interpreted to be the index of the first directory in the file to transmit (directories are numbered starting at zero). faxnumber The number to use when sending a fax. Parallel's FAXNumber device config option. groupid The job group identifier, an integer number in the range 1 to 32000 assigned to each group of jobs by the HylaFAX software. Each job in a group of jobs submitted at the same time is assigned the same value by the HylaFAX software. jobid The job identifier, a unique integer number in the range 1 to 32000 assigned to each job by the HylaFAX software. jobtag A user-specified string that is intended for identification purposes. If this string is defined, it is returned to the user in notification messages instead of the job identifier. killtime The time to kill this job, expressed in seconds since 00:00:00 GMT, January 1, 1970. location The receiver's location as specified with the -y option to sendfax(1). This value is used only when creating continuation cover pages. mailaddr The electronic mail address to which notification messages should be directed. maxdials The maximum number of times the server should dial the phone. If the job cannot be completed in this number of calls, it is terminated. maxtries The maximum number of times the server should attempt to send a job; where an attempt is defined to be a session that makes it past Phase A of the CCITT T.30 protocol (for facsimile), or similar. If the job cannot be completed in this number of tries, it is terminated. minsp The minimum signalling rate to use for transmitting page data: 0 for 2400 bps (default), 1 for 4800 bps, 2 for 7200 bps, 3 for 9600 bps, 4 for 12000 bps, 5 for 14400 bps, 6 for 16800 bps, 7 for 19200 bps, 8 for 21600 bps, 9 for 24000 bps, 10 for 26400 bps, 11 for 28800 bps, 12 for 31200 bps, and 13 for 33600 bps. modem The outgoing modem to use to send the job, or ``any'' if any available modem is acceptable. owner The identity of the user that owns the job. Typically the owner is the user that created the job, though clients with admin- istrative privileges can change the ownership of jobs. The value is the string specified in the USER command passed to hfaxd(8) when a client logins in to the server. notify A specification of whether the sender wants notification: whenever the job is requeued after a failed attempt to transmit (``when requeued''), when the job is completed (``when done''), either of the above (``when done+requeued''), or not at all (``none''). npages The number of pages in the facsimile, including the cover page, that have been successfully transmitted. ntries The number of unsuccessful attempts that have been made to transmit the current page. ndials The number of consecutive unsuccessful attempts to establish carrier with the the remote device. number The dialstring to use to call the destination device. page a string with PIN and to use in processing a page transmit request. pagechop Whether or not to automatically truncate trailing whitespace on pages of outbound facsimile; see PageChop in hylafax-con- fig(5). The possible values are: ``default'' to use the setting of the PageChop configuration parameter, ``none'' to disable page chopping, ``all'' to enable chopping of all pages, and ``last'' to enable chopping of the last page of each document. pagehandling A string that contains per-page information used during facsimile transmission. Most of the information is used in the nego- tiation of session capabilities with optional information used in the implementation of page chopping. The string has three characters, say xxc, for each page to be transmitted. The xx characters are a hex-encoded specification of the session capa- bilities required to transmit the page. The c character is one of ``M'', ``S'', and ``P''; where: ``M'' indicates there is another page to follow and that the page requires different T.30 session parameters be negotiated (an EOM code is to be transmitted). ``S'' indicates there is another page to follow, but the page uses the same session parameters (an MPS. code is to be transmitted). ``P'' indicates this is the last page to be transmitted (an EOP code is to be transmitted). In addi- tion, if page chopping has been enabled and the page has enough trailing whitespace to be a candidate, then each three char- acter string will be followed by a string of the form ``ZXXXX'', where ``XXXX'' is a 4 digit hex-encoded count of the number of bytes of data to send for a chopped page. pagelength The desired page length in millimeters. pagewidth The desired page width in millimeters. pcl The pathname of a PCL document to send. Once a PCL document has been processed by faxsend, it is marked as !pcl so that sub- sequent retries do not reprocess the document. poll The value is a Caller Identification String (CIS) to use in making a polling request. If no CIS is specified then faxsend will form one from the FAXNumber configuration parameter. postscript The pathname of a POSTSCRIPT(R) document to send. Once a POSTSCRIPT document has been processed by faxsend, it is marked as !postscript so that subsequent retries do not reprocess the document. receiver The receiver's name. This value is used only when creating continuation cover pages. resolution The desired vertical resolution in lines per inch. This value should be either 98 or 196. retrytime The time, in seconds, to delay between each attempt to transmit a job that fails because of a communication-oriented problem. Normally jobs are scheduled according to a collection of configuration parameters that are tuned for the specific reason of each failure; e.g. see JobReqProto in hylafax-config(5). returned Used internally to determine the last return value of the job send attempt. sender The ``full name'' of the sender of the facsimile. signalrate The signalling rate used to transmit facsimile data. This item is recorded by faxsend(8) so that notify(8) can return it in a notification message. state The job scheduling state. Recognized values are: 1 (suspended, not being scheduled), 2 (pending, waiting for the time to send), 3 (sleeping, waiting for a scheduled timeout), 4 (blocked, waiting for concurrent activity to the same destination to complete), 5 (ready, ready to be processed except for available resources), 6 (active, actively being processed by HylaFAX), 7 (done, processing completed with success). 8 (failed, processing completed with a failure). status Status information about the current state of the job. Typically this is the reason why the last attempt to send the facsim- ile failed. subaddr The SubAddress information to transmit when sending a facsimile. This string should be used by the receiver to route received facsimile documents. tagline The format string to use in imaging taglines on outgoing documents. Note that this parameter is only used if the desiredtl parameter is non-zero. tiff The pathname of a TIFF/F document to send. Once a TIFF document has been processed by faxsend, it is marked as !tiff so that subsequent retries do not reprocess the document. totdials The total number of times the server has placed a call to the receiving phone number. totpages The total number of pages to be transmitted. tottries The total number of attempts to transmit a job; see maxtries above. tsi TSI to use when sending. This is only used if the device has been configured to allow it. Otherwise, the configured LocalI- dentifier. is used. tts The time to send the job. If this value is non-zero, it is number of seconds since 00:00:00 GMT, January 1, 1970. Other- wise, a value of 0 is interpreted to mean process as soon as possible. useccover 1 if the job should use a continuation cover page during retransmission, 0 otherwise. usexvres 1 if the job should use the highest possible vertical resolution, 0 otherwise. See hylafax-server(5) for a description of continuation cover pages. SEE ALSO
sendfax(1), faxq(8), faxqclean(8), faxsend(8), pagesend(8), hfaxd(8), hylafax-config(5) May 12, 1996 SENDQ(5)
All times are GMT -4. The time now is 06:28 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy