Awk multiple lines with 4th column on to a single line


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Awk multiple lines with 4th column on to a single line
# 8  
Old 10-02-2011
Using Perl:

Code:
$
$
$ cat f10
XXXXXXXXXX1|07/24/2007|1|aaaaaaaaaaabbbbbbbbccccccccccccc
XXXXXXXXXX1|07/26/2007|2|sometxt
XXXXXXXXXX1|07/30/2007|1|some_random_text
XXXXXXXXXX1|08/31/2007|2|new_random.
XXXXXXXXXX1|09/27/2007|3|some_nre_random_test
$
$
$ perl -F"\|" -lane 'if ($F[2] == 1){print $x; $x="$F[0]|$F[1]|$F[3]"} else {$x.=$F[3]} END {print $x}' f10

XXXXXXXXXX1|07/24/2007|aaaaaaaaaaabbbbbbbbcccccccccccccsometxt
XXXXXXXXXX1|07/30/2007|some_random_textnew_random.some_nre_random_test
$
$
$

tyler_durden
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. 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

2. 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

3. 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

4. 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

5. 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

6. 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

7. 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

8. 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

9. 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

10. 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
Login or Register to Ask a Question
SYNCTEX(5)						      BSD File Formats Manual							SYNCTEX(5)

NAME
synctex -- Synchronize TeXnology help file DESCRIPTION
Synchronize TeXnology help file (synctexs) are text files that help input/output synchronization during document preparation with the TeX typesetting system. BASICS
The structure of this file should not be considered public, in the sense that no one should need to parse its contents, except the synctex command line utility, and the synctex_parser library. Unless it is absolutely not avoidable, access to the contents of the synctex file should only be made through requests made to the synctex command line utility. STRUCTURE
The element structure of a synctex file is a list of text line records as follows. '*', '+', and '?' have their usual EBNF meanings: '*' means zero or more, '+' means one or more, and '?' means zero or one (i.e., optional). <SyncTeX> ::= (The whole contents in 4 sections) <Preamble> <Content> <Postamble> <Post Scriptum> Each section starts with the first occurrence of a sectioning line, and ends with the next section, if any. In the following definitions, we do not mention the section ending condition. The preamble <Preamble> ::= "SyncTeX Version:" <Version Number> <EOL> <Input Line>* "Magnification:" <TeX magnification> <EOL> "Unit:" <unit in scaled point> <EOL> "X Offset:" <horizontal offset in scaled point> <EOL> "Y Offset:" <vertical offset in scaled point> <EOL> <Input Line> ::= "Input:" <tag> ":" <File Name> <EOL> The content <Content> ::= <byte offset record> "Content:" <EOL> <sheet(1)> <Input Line>* <sheet(2)> <Input Line>* ... <sheet(N)> <Input Line>* <byte offset record> ::= "!" <byte offset> <end of record> <sheet(n)> ::= <byte offset record> "{" <the integer n> <end of record>/ <box content>* <byte offset record> "}" <the integer n> <end of record> The <box content> describes what is inside a box. It is either a vertical or horizontal box, with some records related to glue, kern or math nodes. <box content> ::= <vbox section>|<hbox section> |<void vbox record>|<void hbox record> |<current record>|<glue record>|<kern record>|<math record> <vbox section> ::= "[" <link> ":" <point> ":" <size> <end of record> <box content>* "]" <end of record> <hbox section> ::= ( <link> ":" <point> ":" <size> <end of record> <box content>* ")" <end of record> Void boxes: <void vbox record> ::= "v" <link> ":" <point> ":" <size> <end of record> <void hbox record> ::= "h" <link> ":" <point> ":" <size> <end of record> <size> ::= <Width> "," <Height> "," <Depth> <Width> ::= <integer> <Height> ::= <integer> <Depth> ::= <integer> <link> ::= <tag> "," <line>( "," <column>)? <line> ::= <integer> <column> ::= <integer> The forthcoming records are basic one liners. <current record> ::= "x" <link> ":" <point> <end of record> <kern record> ::= "k" <link> ":" <point> ":" <Width> <end of record> <glue record> ::= "g" <link> ":" <point> <end of record> <math record> ::= "$" <link> ":" <point> <end of record> The postamble The postamble closes the file If there is no postamble, it means that the typesetting process did not end correctly. <Postamble>::= <byte offset record> "Count:" <Number of records> <EOL> The post scriptum The post scriptum contains material possibly added by 3rd parties. It allows to append some transformation (shift and magnify). Typically, one applies a dvi to pdf filter with offset options and magnification, then he appends the same options to the synctex file, for example synctex update -o foo.pdf -m 0.486 -x 9472573sp -y 13.3dd source.dvi <Post Scriptum>::= <byte offset record> "Post Scriptum:" <EOL> "Magnification:" <number> <EOL> (Set additional magnification) "X Offset:" <dimension> <EOL> (Set horizontal offset) "Y Offset:" <dimension> <EOL> (Set vertical offset) This second information will override the offset and magnification previously available in the preamble section. All the numbers are encoded using the decimal representation with "C" locale. USAGE
The <current record> is used to compute the visible size of hbox's. The byte offset is an implicit anchor to navigate the synctex file from sheet to sheet. Independant Mar 13, 2012 Independant