Sponsored Content
Top Forums Shell Programming and Scripting Issue with Joining lines from two files Post 302356138 by sharath160 on Thursday 24th of September 2009 04:04:35 PM
Old 09-24-2009
Issue with Joining lines from two files

Hi,
I have two text files, that need their data joining/concatenation. 'Paste' works for this.
But have an issue when there is mismatch in number of rows in each file.
E.g.
(main file) File1 - has 20 rows
File2 - has 30 rows.
Command 'paste file1 file2 > file3' joins all lines.
I want the output for only 20 rows, i.e. the joining for only the number of rows present in first file(file1) and dont want extra rows.

Can you please help me out on this?

Regards,
Sharath.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Joining 3 lines at a time

Hi, I have a file which has the contents as below : 07:38:36 EST date 20041117 07:39:06 EST 07:00:29 EDT date 20050504 07:25:16 EDT 07:00:40 EDT date 20050505 07:23:12 EDT I need to delete the new line character from all lines except 3rd,6th,9th etc. lines so that i get the output... (14 Replies)
Discussion started by: Sabari Nath S
14 Replies

2. Shell Programming and Scripting

Joining lines from two files - please help

Hello, I have 2 files say File 1 has ABC DEF GHI File 2 has 123 456 789 I need output as ABC 123 DEF 456 GHI 789 I tried awk and sed but not able to get it in the right way. :confused: Please help. Thanks (25 Replies)
Discussion started by: chandra004
25 Replies

3. Shell Programming and Scripting

joining two lines

Hi , I want to join two lines in a file, where the second line contain query string. if it doesn't contain that string i don't want to join e.g. Input file is as following: name fame game none none none name fame game cat eat mice I need output file as name fame game none none... (2 Replies)
Discussion started by: ashrafonics
2 Replies

4. Shell Programming and Scripting

Need help joining lines

Hi All, I need the command to join 2 lines into one. I found lots of threads but none give me the sollution. Probably because unix scripting is one of my best features ;) I got a logfile where line 2 needs to be joined with line 1, lines 4 needs to be joined with line 3 etc If you need... (16 Replies)
Discussion started by: rene21976
16 Replies

5. Shell Programming and Scripting

pattern matching lines using the date, and then joining the lines

Hi Guys, Was trying to attempt the below using awk and sed, have no luck so far, so any help would be appreciated. Current Text File: The first line has got an "\n", and the second line has got spaces/tabs then the word and "\n" TIME SERVER/CLIENT TEXT... (6 Replies)
Discussion started by: eo29
6 Replies

6. Shell Programming and Scripting

Joining lines in different way

Hi all, I'm excited to the part of unix.com forum, and noob to it. I have an query, where I have an file and it contains data like this use thread when posting do no I was expecting the result as use thread thread when when posting posting do do no use thread when thread when... (6 Replies)
Discussion started by: Jose Nirmal
6 Replies

7. Shell Programming and Scripting

Joining broken lines and removing empty lines

Hi - I have req to join broken lines and remove empty lines but should NOT be in one line. It has to be as is line by line. The challenge here is there is no end of line/start of line char. thanks in advance Source:- 2003-04-34024|04-10-2003|Claims|Claim|01-13-2003|Air Bag:Driver;... (7 Replies)
Discussion started by: Jackceasar123
7 Replies

8. Shell Programming and Scripting

Issue in Concatenation/Joining of lines in a dynamically generated file

Hi, I have a file containing many records delimited by pipe (|). Each record should contain 17 columnns/fields. there are some fields having fields less than 17.So i am extracting those records to a file using the below command awk 'BEGIN {FS="|"} NF !=17 {print}' feedfile.txt... (8 Replies)
Discussion started by: TomG
8 Replies

9. Shell Programming and Scripting

UNIX joins : facing issue while joining three files

Hello , I have three files : sampleoutput1.txt has columns (in the following order) : hostname ; available patches , available packages sampleoutput2.txt has columns (in the following order) : hostname ; patchwave ; BSID ; Application sampleoutput3.txt has columns (in the following... (10 Replies)
Discussion started by: rahul2662
10 Replies

10. UNIX for Beginners Questions & Answers

Issue with awk when joining two files when field has '-' hyphen

Dear Community; I need to join two files but I am facing issues. 1st file has multiple columns. Primary (1st) columns has unique values. There are other columns out of which some has non-ascii characters as well (other language). Example File below: 1-1001JRL,BiRecurring... (5 Replies)
Discussion started by: mystition
5 Replies
paste(1)						      General Commands Manual							  paste(1)

NAME
paste - merge same lines of several files or subsequent lines of one file SYNOPSIS
file1 file2 ... list file1 file2 ... list] file1 file2 ... DESCRIPTION
In the first two forms, concatenates corresponding lines of the given input files file1, file2, etc. It treats each file as a column or columns in a table and pastes them together horizontally (parallel merging). In other words, it is the horizontal counterpart of cat(1) which concatenates vertically; i.e., one file after the other. In the option form above, replaces the function of an older command with the same name by combining subsequent lines of the input file (serial merging). In all cases, lines are glued together with the tab char- acter, or with characters from an optionally specified list. Output is to standard output, so can be used as the start of a pipe, or as a filter if is used instead of a file name. recognizes the following options and command-line arguments: Without this option, the new-line characters of all but the last file (or last line in case of the option) are replaced by a tab character. This option allows replac- ing the tab character by one or more alternate characters (see below). list One or more characters immediately following replace the default tab as the line concatenation character. The list is used circularly; i.e., when exhausted, it is reused. In parallel merging (that is, no option), the lines from the last file are always terminated with a new-line character, not from the list. The list can contain the special escape sequences: (new-line), (tab), (backslash), and (empty string, not a null character). Quoting may be necessary if charac- ters have special meaning to the shell. (For example, to get one backslash, use ). Merge subsequent lines rather than one from each input file. Use tab for concatenation, unless a list is specified with the option. Regardless of the list, the very last character of the file is forced to be a new-line. Can be used in place of any file name to read a line from the standard input (there is no prompting). EXTERNAL INFLUENCES
Environment Variables determines the locale for the interpretation of text as single- and/or multi-byte characters. determines the language in which messages are displayed. If or is not specified in the environment or is set to the empty string, the value of is used as a default for each unspecified or empty variable. If is not specified or is set to the empty string, a default of "C" (see lang(5)) is used instead of If any internationalization variable contains an invalid setting, behaves as if all internationalization variables are set to "C". See environ(5). International Code Set Support Single- and multi-byte character code sets are supported. RETURN VALUE
These commands return the following values upon completion: Completed successfully. An error occurred. EXAMPLES
List directory in one column: List directory in four columns Combine pairs of lines into lines Notes works similarly, but creates extra blanks, tabs and new-lines for a nice page layout. DIAGNOSTICS
Except for the option, no more than - 3 input files can be specified (see limits(5)). AUTHOR
was developed by OSF and HP. SEE ALSO
cut(1), grep(1), pr(1). STANDARDS CONFORMANCE
paste(1)
All times are GMT -4. The time now is 07:23 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy