Sponsored Content
Top Forums Shell Programming and Scripting Append 1st field from a file into 2nd field of another file Post 302483281 by Scrutinizer on Saturday 25th of December 2010 05:13:43 AM
Old 12-25-2010
You could use paste, but that would leave a space...
Code:
paste -d' ' file1 file2

A general solution would be this:
Code:
awk '{p=$1;getline<f;print p$1}' f=file2 file

or rather,
Code:
awk '{p=$m;getline<f;print p$n}' m=1 n=1 f=file2 file


Last edited by Scrutinizer; 12-25-2010 at 06:21 AM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

append field to file(nawk)

I have two files. File A and File B. File A has two fields separated by comma 352020252365988, 652020100572356 546876543215667, 652065465654686 ... File B has many Fields separate by spaces Date Name 352020252365988 Reference Date2 Name2 546876543215667 Reference I want to... (4 Replies)
Discussion started by: axl
4 Replies

2. Shell Programming and Scripting

Append a field to the end of each line of a file based on searching another file.

Hi All, I have two comma separated value(CSV) files, say FileA and FileB. The contents looks like that shown below. FileA EmpNo,Name,Age,Sex, 1000,ABC,23,M, 1001,DES,24,F, ... (2 Replies)
Discussion started by: ultimate
2 Replies

3. Shell Programming and Scripting

Sort alpha on 1st field, numerical on 2nd field (sci notation)

I want to sort alphabetically on the first field and sort in descending numerical order on the 2nd field. With a normal "sort -r -n" it does this: abc ||| 5e-05 ||| bla abc ||| 3 ||| ble def ||| 1 ||| abc def ||| 0.2 ||| def As you can see it ignores the fact that 5e-05 is actually 0.00005... (1 Reply)
Discussion started by: FrancoisCN
1 Replies

4. Shell Programming and Scripting

Appending 1st field in a file into 2nd field in another file

Hi, I've internally searched through forums for about 2+ hours. Unfortunately, with no luck. Although I've found some cases close to mine below, but didn't help so much. Actually, I'm in short with time. So I had to post my case. Hoping that you can help. I have 2 files, FILE1 ... (0 Replies)
Discussion started by: amurib
0 Replies

5. Shell Programming and Scripting

Compare a common field in two files and append a column from File 1 in File2

Hi Friends, I am new to Shell Scripting and need your help in the below situation. - I have two files (File 1 and File 2) and the contents of the files are mentioned below. - "Application handle" is the common field in both the files. (NOTE :- PLEASE REFER TO THE ATTACHMENT "Compare files... (2 Replies)
Discussion started by: Santoshbn
2 Replies

6. Shell Programming and Scripting

Compare two files Field by field and output the result in another file

Hi Friends, Need Help. I have file1.txt as File1.txt |123|A|7267|Hyder|Cross|Sell|7801 |995|A|7051|2008|Lunar|New|Year|Promotion|7801 |996|A|7022|Q108|Targ|Prospect|&|SSCC|Savings|Promo|7801 |997|A|7182|Q1|Feb-Apr|08|Credit|ITA|PA|SBA|Campaign|7801 File2.txt... (7 Replies)
Discussion started by: i150371485
7 Replies

7. Linux

How do I format a Date field of a .CSV file with multiple commas in a string field?

I have a .CSV file (file.csv) whose data are all enclosed in double quotes. Sample format of the file is as below: column1,column2,column3,column4,column5,column6, column7, Column8, Column9, Column10 "12","B000QRIGJ4","4432","string with quotes, and with a comma, and colon: in... (3 Replies)
Discussion started by: dhruuv369
3 Replies

8. Shell Programming and Scripting

Command/script to match a field and print the next field of each line in a file.

Hello, I have a text file in the below format: Source Destination State Lag Status CQA02W2K12pl:D:\CAQA ... (10 Replies)
Discussion started by: pocodot
10 Replies

9. UNIX for Dummies Questions & Answers

Combine Similar Output from the 2nd field w.r.t 1st Field

Hi, For example: I have: HostA,XYZ HostB,XYZ HostC,ABC I would like the output to be: HostA,HostB: XYZ HostC:ABC How can I achieve this? So far what I though of is: (1 Reply)
Discussion started by: alvinoo
1 Replies

10. UNIX for Beginners Questions & Answers

Compare 1st column from 2 file and if match print line from 1st file and append column 7 from 2nd

hi I have 2 file with more than 10 columns for both 1st file apple,0,0,0...... orange,1,2,3..... mango,2,4,5..... 2nd file apple,2,3,4,5,6,7... orange,2,3,4,5,6,8... watermerlon,2,3,4,5,6,abc... mango,5,6,7,4,6,def.... (1 Reply)
Discussion started by: tententen
1 Replies
SoMFShort(3)							       Coin							      SoMFShort(3)

NAME
SoMFShort - The SoMFShort class is a container for short integer values. This field is used where nodes, engines or other field containers needs to store a group of multiple short integer values. SYNOPSIS
#include <Inventor/fields/SoMFShort.h> Inherits SoMField. Public Member Functions virtual SoType getTypeId (void) const virtual void copyFrom (const SoField &field) const SoMFShort & operator= (const SoMFShort &field) virtual SbBool isSame (const SoField &field) const short operator[] (const int idx) const const short * getValues (const int start) const int find (short value, SbBool addifnotfound=FALSE) void setValues (const int start, const int num, const short *newvals) void set1Value (const int idx, short value) void setValue (short value) short operator= (short val) SbBool operator== (const SoMFShort &field) const SbBool operator!= (const SoMFShort &field) const short * startEditing (void) void finishEditing (void) void setValuesPointer (const int num, const short *userdata) void setValuesPointer (const int num, short *userdata) Static Public Member Functions static void * createInstance (void) static SoType getClassTypeId (void) static void initClass (void) Protected Member Functions virtual void deleteAllValues (void) virtual void copyValue (int to, int from) virtual int fieldSizeof (void) const virtual void * valuesPtr (void) virtual void setValuesPtr (void *ptr) virtual void allocValues (int num) Protected Attributes short * values Detailed Description The SoMFShort class is a container for short integer values. This field is used where nodes, engines or other field containers needs to store a group of multiple short integer values. This field supports application data sharing through a setValuesPointer() method. See SoMField documentation for information on how to use this function. See also: SoSFShort Member Function Documentation SoType SoMFShort::getClassTypeId (void) [static] Returns a unique type identifier for this field class. See also: getTypeId(), SoType Reimplemented from SoMField. SoType SoMFShort::getTypeId (void) const [virtual] Returns the type identification instance which uniquely identifies the Coin field class the object belongs to. See also: getClassTypeId(), SoType Implements SoField. void SoMFShort::copyFrom (const SoField &f) [virtual] Copy value(s) from f into this field. f must be of the same type as this field. Implements SoField. SbBool SoMFShort::isSame (const SoField &f) const [virtual] Check for equal type and value(s). Implements SoField. void SoMFShort::deleteAllValues (void) [protected], [virtual] This API member is considered internal to the library, as it is not likely to be of interest to the application programmer. Implements SoMField. void SoMFShort::copyValue (intto, intfrom) [protected], [virtual] This method is used for moving values around internally within a multivalue field. It needs to be overridden in each field so it automatically takes care of running copy contructors where necessary. Implements SoMField. const short* SoMFShort::getValues (const intstart) const [inline] Returns a pointer to the values array. void SoMFShort::initClass (void) [static] Internal method called upon initialization of the library (from SoDB::init()) to set up the type system. Reimplemented from SoMField. Author Generated automatically by Doxygen for Coin from the source code. Version 3.1.3 Wed May 23 2012 SoMFShort(3)
All times are GMT -4. The time now is 08:05 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy