Sponsored Content
Top Forums Shell Programming and Scripting Awk multiple lines with 4th column on to a single line Post 302560734 by Vasan on Friday 30th of September 2011 05:39:21 PM
Old 09-30-2011
Thanks.

But I am not getting the right output..

Here is what I got
Code:
$ cat FILENAME|awk -F"|" '{print $1,$2,$4}' |tr " " "\|"
XXXXXXXXXX1|07/24/2007|aaaaaaaaaaabbbbbbbbccccccccccccc
XXXXXXXXXX1|07/24/2007|sometxt
XXXXXXXXXX1|07/30/2007|some_random_text
XXXXXXXXXX1|07/30/2007|new_random.
XXXXXXXXXX1|09/27/2007|some_nre_random_test
XXXXXXXXXX1|09/27/2007|blabla
XXXXXXXXXX1|09/27/2007|fixed_text_random
XXXXXXXXXX1|11/14/2007|blabla
XXXXXXXXXX1|11/28/2007|junk_text
XXXXXXXXXX2|12/21/2007|Notes


Am I missing something..

Thanks

Last edited by Franklin52; 10-01-2011 at 05:56 AM.. Reason: Please use code tags for data and code samples, thank you
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

replacing multiple lines with single line

Can any one give me the idea on replacing multiple blank lines with a single blank line? Please conside it for a file having more than 100 number of characters. Regards, Siba (3 Replies)
Discussion started by: siba.s.nayak
3 Replies

2. Shell Programming and Scripting

Awk multiple lines with 3rd column onto a single line?

I have a H U G E file with over 1million entries in it. Looks something like this: USER0001|DEVICE001|VAR1 USER0001|DEVICE001|VAR2 USER0001|DEVICE001|VAR3 USER0001|DEVICE001|VAR4 USER0001|DEVICE001|VAR5 USER0001|DEVICE001|VAR6 USER0001|DEVICE002|VAR1 USER0001|DEVICE002|VAR2... (4 Replies)
Discussion started by: SoMoney
4 Replies

3. Shell Programming and Scripting

Multiple lines into a single line

Hi, I've some files with the following data and i need to convert the lines between the separator ---, into a single line. I've tried with the paste cmd but my main problem is that the number of lines between the separator is not fix, it can very between 1-4 lines. Input --- 2010-02-22... (4 Replies)
Discussion started by: RickyC9999
4 Replies

4. Shell Programming and Scripting

Combine multiple lines in single line

This is related to one of my previous post but now with a slight difference: I need the "Updated:" to be in one line as well as the "Information:" on one line as well. These are in multiple lines right now as seen below. These can have 2 or more lines that needs to be in one line. System name:... (8 Replies)
Discussion started by: The One
8 Replies

5. Shell Programming and Scripting

Multiple lines in a single column to be merged as a single line for a record

Hi, I have a requirement with, No~Dt~Notes 1~2011/08/1~"aaa bbb ccc ddd eee fff ggg hhh" Single column alone got splitted into multiple lines. I require the output as No~Dt~Notes 1~2011/08/1~"aaa<>bbb<>ccc<>ddd<>eee<>fff<>ggg<>hhh" mean to say those new lines to be... (1 Reply)
Discussion started by: Bhuvaneswari
1 Replies

6. Shell Programming and Scripting

Awk match multiple columns in multiple lines in single file

Hi, Input 7488 7389 chr1.fa chr1.fa 3546 9887 chr5.fa chr9.fa 7387 7898 chrX.fa chr3.fa 7488 7389 chr21.fa chr3.fa 7488 7389 chr1.fa chr1.fa 3546 9887 chr9.fa chr5.fa 7898 7387 chrX.fa chr3.fa Desired Output 7488 7389 chr1.fa chr1.fa 2 3546 9887 chr5.fa chr9.fa 2... (2 Replies)
Discussion started by: jacobs.smith
2 Replies

7. Shell Programming and Scripting

Making multiple lines as single line

Hi All, I have a spool file which as shown below. I want to make it as single line after every semicolon. In this case there should be 2 lines in vi editor. I am not used to use sed so could you guys please help me out ? exec spk_dba.sp_runsql('ALP','CREATE DATABASE LINK "TEST" CONNECT TO... (2 Replies)
Discussion started by: nicolas38
2 Replies

8. Shell Programming and Scripting

Coverting multiple lines to a single line

Hi all, I have a requirement to covert multiple lines in a comma delimited file to a single line through shell scripting. We should compare the data in the first column in each line. If it is same, then the other data should be put in the same line.Below is the sample input and expected output:... (4 Replies)
Discussion started by: Bobby_2000
4 Replies

9. UNIX for Beginners Questions & Answers

Merging multiple lines into single line based on one column

I Want to merge multiple lines based on the 1st field and keep into single record. SRC File: AAA_POC_DB.TAB1 AAA_POC_DB.TAB2 AAA_POC_DB.TAB3 AAA_POC_DB.TAB4 BBB_POC_DB.TAB1 BBB_POC_DB.TAB2 CCC_POC_DB.TAB6 OUTPUT ----------------- 'AAA_POC_DB','TAB1','TAB2','TAB3','TAB4'... (10 Replies)
Discussion started by: raju2016
10 Replies

10. UNIX for Beginners Questions & Answers

Multiple lines to single line

I have code as below # create temporary table `temp4277`(key(waybill_no)) select waybill_no,concat_ws('',card_type,card_series_no) cardinfo from rfid_temp_ticket where waybill_no='4277' group by... (4 Replies)
Discussion started by: kaushik02018
4 Replies
srec_signetics(5)						File Formats Manual						 srec_signetics(5)

NAME
srec_signetics - Signetics file format DESCRIPTION
The Signetics file format is not often used. The major disadvantage in modern applications is that the addressing range is limited to only 64kb. Records All data lines are called records, and each record contains the following 5 fields: +--+------+----+----+----+----+ |: | aaaa | cc | as | dd | ss | The field are defined as follows: +--+------+----+----+----+----+ : Every record starts with this identifier. aaaa The address field. A four digit (2 byte) number representing the first address to be used by this record. cc The byte-count. A two digit value (1 byte), counting the actual data bytes in the record. as Address checksum. Covers 2 address bytes and the byte count. dd The actual data of this record. There can be 1 to 255 data bytes per record (see cc) ss Data Checksum. Covers only all the data bytes of this record. Record Begin Every record begins with a colon ":[rq] character. Records contain only ASCII characters. No spaces or tabs are allowed in a record. In fact, apart from the 1st colon, no other characters than 0..9 and A..F are allowed in a record. Interpretation of a record should be case less, it does not matter if you use a..f or A..F. Unfortunately the colon was chosen for the Signetics file format, similar to the Intel format (see srec_intel(5) for more information). However, SRecord is able to automatically detect the dofference between the two format, when you use the -Guess format specifier. Address Field This is the address where the first data byte of the record should be stored. After storing that data byte, the address is incremented by 1 to point to the address for the next data byte of the record. And so on, until all data bytes are stored. The address is represented by a 4 digit hex number (2 bytes), with the MSD first. The order of addresses in the records of a file is not important. The file may also contain address gaps, to skip a portion of unused memory. Byte Count The byte count cc counts the actual data bytes in the current record. Usually records have 32 data bytes, but any number between 1 and 255 is possible. A value of 0x00 for cc indicates the end of the file. In this case not even the address checksum will follow! The record (and file) are terminated immediately. It is not recommended to send too many data bytes in a record for that may increase the transmission time in case of errors. Also avoid sending only a few data bytes per record, because the address overhead will be too heavy in comparison to the payload. Address Checksum This is not really a checksum anymore, it looks more like a CRC. The checksum can not only detect errors in the values of the bytes, but also bytes out of order can be detected. The checksum is calculated by this algorithm: checksum = 0 for i = 1 to 3 checksum = checkum XOR byte ROL checksum next i For the Address Checksum we only need 2 Address bytes and 1 Byte Count byte to be added. That's why we count to 3 in the loop. Every byte is XORed with the previous result. Then the intermediate result is rolled left (carry rolls back into b0). This results in a very reliable checksum, and that for only 3 bytes! The last record of the file does not contain any checksums! So the file ends right after the Byte Count of 0. Data Field The payload of the record is formed by the Data field. The number of data bytes expected is given by the Byte Count field. The last record of the file may not contain a Data field. Data Checksum This checksum uses the same algorithm as used for the Address Checksum. This time we calculate the checksum with only the data bytes of this record. checksum = 0 for i = 1 to cc checksum = checksum XOR byte ROL checksum next i Note that we count to the Byte Count cc this time. Size Multiplier In general, binary data will expand in sized by approximately 2.4 times when represented with this format. EXAMPLE
Here is an example Signetics file :B00010A5576F77212044696420796F75207265617B :B01010E56C6C7920676F207468726F756768206136 :B02010256C6C20746861742074726F75626C652068 :B0300D5F746F207265616420746869733FD1 :B03D00 In the example above you can see a piece of code in Signetics format. The first 3 lines have 16 bytes of data each, which can be seen by the byte count. The 4th line has only 13 bytes, because the program is at it's end there. Notice that the last record of the file contains no data bytes, and not even an Address Checksum. SEE ALSO
http://sbprojects.fol.nl/knowledge/fileformats/signetics.htm AUTHOR
This man page was taken from the above Web page. It was written by San Bergmans <sanmail@bigfoot.com> Reference Manual SRecord srec_signetics(5)
All times are GMT -4. The time now is 05:57 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy