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


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Appending 1st field in a file into 2nd field in another file
# 1  
Old 12-25-2010
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

23444,
12333,
55578,

FILE2
8
9
8

I want to

(a) append the filed in FILE2, into 2nf field of FILE1:

23444, 8
12333, 9
55578, 8

and in other run

(b) append the filed in FILE2, into FILE1 as follows:

23444,8
12333,9
55578,8

In ADDITION & generally, can you provide me with a solution that:
extracts the "Nth" field from FILE1 into the "Mth" filed in FILE2?

Waiting for your input, with my appreciation in advance.

BR,
Ahmed
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Need to replace last field in a file,if first field matches

Hi, Need to replace last field in a file(/etc/passwd) ,if first filed matches with particular username. Scenario: cat testfor1 deekshi:x:7082:7082::/home/deekshi:/bin/bash harini1:x:7083:7083::/home/harini1:/bin/bash Here,if first field contains "deekshi", then i should replace... (4 Replies)
Discussion started by: Sumanthsv
4 Replies

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

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

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

5. Shell Programming and Scripting

Appending information from 2nd file into 1st based on intervals

Hi, I am trying to gather information from the second file and append it to the first file. input HWUSI-EAS000_29:1:100:10000:11479#0/1 + chr5 14458050 ATTGGCTGAGGTCCTACTAGTTGTGATGTGTAAGTGT HHHHHHGDGGEDGGGDGCGEDDEFFFAGE 0 second file:... (14 Replies)
Discussion started by: Diya123
14 Replies

6. Shell Programming and Scripting

Plz Help. Compare 2 files field by field and get the output in another file.

Hi Freinds, I have 2 files . one is source.txt and second one is target.txt. I want to keep source.txt as baseline and compare target.txt. please find the data in 2 files and Expected output. Source.txt 1|HYD|NAG|TRA|34.5|1234 2|CHE|ESW|DES|36.5|134 3|BAN|MEH|TRA|33.5|234... (5 Replies)
Discussion started by: i150371485
5 Replies

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

8. Shell Programming and Scripting

Append 1st field from a file into 2nd field of 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 ... (1 Reply)
Discussion started by: amurib
1 Replies

9. Shell Programming and Scripting

Appending a new field at the end in a file

can anyone tell me please ......how to append a new field at the end of a file with the help of sed or some other command in bourne shell (8 Replies)
Discussion started by: amitpta
8 Replies

10. 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
Login or Register to Ask a Question
HTML::FormFu::Deflator::CompoundSplit(3pm)		User Contributed Perl Documentation		HTML::FormFu::Deflator::CompoundSplit(3pm)

NAME
HTML::FormFu::Deflator::CompoundSplit - CompoundSplit deflator SYNOPSIS
--- element: - type: Multi name: address elements: - name: number - name: street deflator: - type: CompoundSplit # set the default $form->get_field('address')->default( $address ); DESCRIPTION
Deflator to allow you to set several field's values at once. For use with a HTML::FormFu::Element::Multi group of fields. A default value passed to the Multi field will be split according to the "split" setting, and its resulting parts passed to its child elements. METHODS
split Arguments: $regex Default Value: "qr/ +/" Regex used to split the default value. Defaults to a regex matching 1 or more space characters. join Arguments: $string Default Value: ' ' If spliting the value results in more parts than there are fields, any extra parts are joined again to form the value for the last field. The value of "join" is used to join these values. Defaults to a single space. For example, if the Multi element contains fields "number" and "name", and is given the value "10 Downing Street"; when split this results in 3 parts: 10, "Downing" and "Street". In this case, the 1st part, 10 is assigned to the first field, and the 2nd and 3rd parts are re- joined with a space to give the single value "Downing Street", which is assigned to the 2nd field. field_order Arguments: @order If the parts from the split value should be assigned to the fields in a different order, you must provide an arrayref containing the names, in the order they should be assigned to. --- element: - type: Multi name: address elements: - name: street - name: number deflator: - type: CompoundSplit field_order: - number - street AUTHOR
Carl Franks LICENSE
This library is free software, you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.14.2 2012-01-23 HTML::FormFu::Deflator::CompoundSplit(3pm)