Sponsored Content
Top Forums Shell Programming and Scripting join on a file with multiple lines, fields Post 302268098 by radoulov on Monday 15th of December 2008 03:50:46 AM
Old 12-15-2008
Quote:
Originally Posted by crimper
[...]
The only problem remains is that the space is assumed as the FS in the regexp, is there a way to escape the FS in a regexp?
What should be the desired output, given the sample data above?
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

join on multiple fields

Is it possible to do a join on multiple fields of two files? I am trying to do something like join -t, -1 2,3 -2 2,3 -o 2.1,2.2,2.3,1.3 filea fileb I want the join to be on columns 2 and 3 of filea and columns 2 and 3 of fileb. What is hapenning is that the second file that I want to do the join... (1 Reply)
Discussion started by: reggiej
1 Replies

2. Shell Programming and Scripting

Awk Join multiple lines

Hi, I have data with broken lines: Sample data: "12"|"25"|"a"|"b"|"c"|"d"|"e"|"f"|"2453748"|"08:10:50" "16"|"25"|"a"|"b"|"c"|"d"|"e"|"f"|" 2453748"|"08:15:50" "16"|"25"|"a"|"b"|" c"|"d"|"e"|"f"|"2453748"|"08:19:50" "16"|"25"|"a"|"b"|"c"|"d"|"e"|"f"|"2453748"|"08:19:50" In the... (5 Replies)
Discussion started by: hitmansilentass
5 Replies

3. Shell Programming and Scripting

How to use SED to join multiple lines?

Hi guys, anyone know how can i join multiples lines using sed till the end of a file and output to another file in a single line? The end of each line will be replaced with a special char "#". I am using the below SED command, however it seems to remove the last 2 lines. Also not all lines... (12 Replies)
Discussion started by: DrivesMeCrazy
12 Replies

4. UNIX for Dummies Questions & Answers

Need help with Join on multiple fields

Hi, I need help with the join command I have 2 files that I want to join on multiple fields. I want to return all records from file 1 I also want empty fields in my joined file if there isn't a match in file 2 I have already sorted them so I know they are in the same order. file1 ... (0 Replies)
Discussion started by: shunter0810
0 Replies

5. Shell Programming and Scripting

Join fields from files with duplicate lines

I have two files, file1.txt: 1 abc 2 def 2 dgh 3 ijk 4 lmn file2.txt 1 opq 2 rst 3 uvw My desired output is: 1 abc opq 2 def rst 2 dgh rst 3 ijk uvw (2 Replies)
Discussion started by: xan.amini
2 Replies

6. Shell Programming and Scripting

Join multiple lines

Hi I have a source file ( written i C ) where a funtion call is spread over multiple lines, for example : func( a, b, c ); I want this to be joined into one single line : func(a,b,c); How can this be done with awk and sed ? Regards. Hench (2 Replies)
Discussion started by: hench
2 Replies

7. Shell Programming and Scripting

Join common patterns in multiple lines into one line

Hi I have a file like 1 2 1 2 3 1 5 6 11 12 10 2 7 5 17 12 I would like to have an output as 1 2 3 5 6 10 7 11 12 17 any help would be highly appreciated Thanks (4 Replies)
Discussion started by: Harrisham
4 Replies

8. Shell Programming and Scripting

Join fields in a same file based on condition

I have an input file like this... All iI want to do is If the lines are identical except for the last field i want to merge them into single line input_file I feel something is nothing I feel something is everything apple mango banana apple mango grapes I want to get output like this:... (3 Replies)
Discussion started by: raj_k
3 Replies

9. Shell Programming and Scripting

Join files on multiple fields

Hello all, I want to join 2 tabbed files on the first 2 fields, and filling the missing values with 0. The 3rd column in each file is constant for the entire file. file1 12658699 ST5 XX2720 0 1 0 1 53039541 ST5 XX2720 1 0 1.5 1 file2 ... (6 Replies)
Discussion started by: sheetalk
6 Replies

10. Shell Programming and Scripting

Join multiple lines from text file

Hi Guys, Could you please advise how to join multiple details lines into single row, with HEADER 1 as the record separator and comma(,) as the field separator. Input: HEADER 1, HEADER 2, HEADER 3, 11,22,33, COLUMN1,COLUMN2,COLUMN3, AA1, BB1, CC1, END: ABC HEADER 1, HEADER 2,... (3 Replies)
Discussion started by: budz26
3 Replies
join-dctrl(1)						      General Commands Manual						     join-dctrl(1)

NAME
join-dctrl - perform relational join on data in dctrl format SYNOPSIS
join-dctrl [ options ] filename filename join-dctrl --version join-dctrl --help DESCRIPTION
join-dctrl performs a relational join operation on data given to it in Debian control file format. A join field must be specified using either the switches -1 and -2 or the switch -j. Conceptually, the program creates all ordered pairs of records that can be formed by having a record from the first file as the first member of the pair and having a record from the second file as the second member of the pair; and then it deletes all such pairs where the join fields are not equal. Effectively, each of the input files is treated as a relational database table. Every input file must be in ascending order on its join field; this allows the program to work fast. The sort-dctrl(1) program can be used to make it so. OPTIONS
-1 field, --1st-join-field=field Specify the join field of the first input file. -2 field, --2nd-join-field=field Specify the join field of the second input file. -j field, --join-field=field Specify a common join field for all files. -a fileno, --unpairable-from=fileno Specify that unmatched paragraphs from the first (if 1 is given) or the second (if 2 is given) file are printed. -o fieldspec, --output-fields=fieldspec Specify which fields are included in the output. Fields are separated by commas (more than one -o option can be used, too). Each field is specified in the format fileno.field in which fileno is the ordinal number of the input file from which the field is drawn (either 1 or 2), and field gives the name of the field to use. As a special case, simple 0 can be used instead of fileno.field to refer to the common value of the join fields. The name of the field (not including the file number) is used in the output as the name of the field. However, a different name for output purposes can be specified by suffixing the field specification by a colon and the preferred visible name. For example, the option -o 0,1.Version:Old-Version,2.Version specifies that the first field in any output record should be the join field, the second field should be Old-Version drawing its data from the Version field of the first input file, and the third field should be Version drawing its data from the field with the same name in the second input file, and these are the only fields in an output record. If no -o option is given, all fields of all the records being joined are included in the output. -l level, --errorlevel=level Set log level to level. level is one of fatal, important, informational and debug, but the last may not be available, depending on the compile-time options. These categories are given here in order; every message that is emitted when fatal is in effect, will be emitted in the important error level, and so on. The default is important. -V, --version Print out version information. -C, --copying Print out the copyright license. This produces much output; be sure to redirect or pipe it somewhere (such as your favourite pager). -h, --help Print out a help summary. OPERANDS
join-dctrl will treat each file named on the command line as a relational database table. A file called - represents the program's stan- dard input stream. Currently, exactly two files must be named. STDIN
The standard input stream may be used as input as specified above in the OPERANDS section. INPUT FILES
All input to join-dctrl is in the format of a Debian control file. A Debian control (dctrl) file is a semistructured single-table database stored in a machine-parseable text file. Such a database consists of a set of records; each record is a mapping from field names to field content. Textually, records are separated by empty lines, while each field is encoded as one or more nonempty lines inside a record. A field starts with its name, followed by a colon, followed by the field content. The colon must reside on the first line of the field, and the first line must start with no whitespace. Subsequent lines, in contrast, always start with linear whitespace (one or more space or tab characters). Each input file must be in the ascending order of its join field. ENVIRONMENT VARIABLES
The standard locale environment, specifically its character set setting, affects the interpretation of input and output as character streams. ASYNCHRONOUS EVENTS
Standard UNIX signals have their usual meaning. STDOUT
All output is sent to the standard output stream. The output is in the format of a Debian control file, described above in the INPUT FILES section. The output will be in the ascending order of the join field, if that field is included in the output. OUTPUT FILES
There are no output files. EXIT STATUS
This utility exits with 0 when successful. It uses a nonzero exit code inconsistently when an error is noticed (this is a bug). CONSEQUENCES OF ERRORS
In case of errors in the input, the output will be partially or completely garbage. In case of errors in invocation, the program will refuse to function. EXAMPLES
Suppose that a file containing data about binary packages for the AMD64 architecture contained in the Debian squeeze (6.0) release, section main, is in the current directory and named Packages. Suppose that we are currently on a Debian system. Suppose further that the current directory does not contain files named stat and pkg. The following commands gives, for each package currently installed and available in Debian squeeze (6.0), its currently installed version (as Old-Version) and the version in squeeze (as New-Version): $ sort-dctrl -kPackage /var/lib/dpkg/status > stat $ sort-dctrl -kPackage Packages > pkg $ join-dctrl -j Package -o 0,1.Version:Old-Version,2.Version:New-Version stat pkg AUTHOR
The join-dctrl program and this manual page were written by Antti-Juhani Kaijanaho. SEE ALSO
grep-dctrl(1), sort-dctrl(1), tbl-dctrl(1) join-dctrl(1)
All times are GMT -4. The time now is 12:54 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy