Sponsored Content
Top Forums Shell Programming and Scripting Reading and appending a row from file1 to file2 using awk or sed Post 302901825 by ida1215 on Friday 16th of May 2014 12:08:24 AM
Old 05-16-2014
Reading and appending a row from file1 to file2 using awk or sed

Hi, I wanted to add each row of file2.txt to entire length of file1.txt given the sample data below and save it as new file. Any idea how to efficiently do it. Thank you for any help.

Code:
input file
file1.txt   file2.txt
140 30    200006 141 32     
140 32    200006 142 33
140 35    200006 142 30
140 36
140 50

desired outputs:
outfile1.txt
140 30 200006 141 32
140 32 200006 141 32
140 35 200006 141 32
140 36 200006 141 32
140 50 200006 141 32

outfile2.txt
140 30 200006 142 33
140 32 200006 142 33
140 35 200006 142 33
140 36 200006 142 33
140 50 200006 142 33

outfile3.txt
140 30 200006 142 30
140 32 200006 142 30
140 35 200006 142 30
140 36 200006 142 30
140 50 200006 142 30

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Awk Compare f1,f2,f3 of File1 with f1 of File2

I have an Awk string-compare problem and have searched the internet and forums for a solution i could use but cannot find a solution i understand to make work with my particular problem: I need to compare (field1 field2 field3 of File1) against (field1 of File2) and if they match print out... (6 Replies)
Discussion started by: RacerX
6 Replies

2. Shell Programming and Scripting

Awk Compare File1 File2 on f2

I'm trying to compare two files using AWK, where if field2 of both files match, replace field1 of file1 with field1 of file2 and if there is no match just print the line of file1. file1.txt (has empty first field) :ABBATOM:B:H:1992 :ABBA TROJAN:B:H:1993 :ABBES FIRST HOPE:B:M:1997 :ABBEYS... (4 Replies)
Discussion started by: RacerX
4 Replies

3. Shell Programming and Scripting

awk/sed search lines in file1 matching columns in file2

Hi All, as you can see I'm pretty new to this board. :D I'm struggling around with small script to search a few fields in another file. Basically I have file1 looking like this: 15:38:28 sz:10001 pr:14.16 15:38:28 sz:10002 pr:18.41 15:38:29 sz:10003 pr:19.28 15:38:30 sz:10004... (1 Reply)
Discussion started by: floripoint
1 Replies

4. Shell Programming and Scripting

[Solved] delete line from file1 by reading from file2

Hi All, I have to arrange one of the text file by deleting specific lines. cat file1.txt 3595 3595 -0.00842773 -0.0085077 0.00368851 12815 12815 -0.00929239 0.00439785 0.0291697 3747 3747 -0.00974353 0.00228922 0.0225058 3574 3574 -0.00711399 -0.00315748 0.0141206 .... 12734... (7 Replies)
Discussion started by: senayasma
7 Replies

5. UNIX for Dummies Questions & Answers

if matching strings in file1 and file2, add column from file1 to file2

I have very limited coding skills but I'm wondering if someone could help me with this. There are many threads about matching strings in two files, but I have no idea how to add a column from one file to another based on a matching string. I'm looking to match column1 in file1 to the number... (3 Replies)
Discussion started by: pathunkathunk
3 Replies

6. Shell Programming and Scripting

Get row number from file1 and print that row of file2

Hi. How can we print those rows of file2 which are mentioned in file1. first character of file1 is a row number.. for eg file1 1:abc 3:ghi 6:pqr file2 a abc b def c ghi d jkl e mno f pqr ... (6 Replies)
Discussion started by: Abhiraj Singh
6 Replies

7. UNIX for Beginners Questions & Answers

Keep only the closet match of timestamped row (include headers) from file1 to precede file2 row/s

My original files are like this below and I distinguish them from the AP_ID (file1 has 572 and file2 has 544). Also, the header on file1 has “G_” pre-pended. NOTE: these are only snippets of very large files and much of the data is not present here. Original File 1: ... (36 Replies)
Discussion started by: aachave1
36 Replies

8. Shell Programming and Scripting

awk to search field2 in file2 using range of fields file1 and using match to another field in file1

I am trying to use awk to find all the $2 values in file2 which is ~30MB and tab-delimited, that are between $2 and $3 in file1 which is ~2GB and tab-delimited. I have just found out that I need to use $1 and $2 and $3 from file1 and $1 and $2of file2 must match $1 of file1 and be in the range... (6 Replies)
Discussion started by: cmccabe
6 Replies

9. Shell Programming and Scripting

awk to update field in file2 if not the same as file1

Trying to use awk to: update $2 in file2 with the $2 value in file1, if $1 in file1 matches $13 in file2, which is tab-delimeted. The $2values may already be the same so in that case nothing happens and the next line is processed. There are exactly 4,605 unique $13 values. Thank you :). ... (4 Replies)
Discussion started by: cmccabe
4 Replies

10. UNIX for Beginners Questions & Answers

Keep only the closet match of timestamped row (include headers) from file1 to precede file2 row/s

This is a question that is related to one I had last August when I was trying to sort/merge two files by millsecond time column (in this case column 6). The script (below) that helped me last august by RudiC solved the puzzle of sorting/merging two files by time, except it gets lost when the... (0 Replies)
Discussion started by: aachave1
0 Replies
deckanji(5)							File Formats Manual						       deckanji(5)

NAME
deckanji - A character encoding system (codeset) for Japanese DESCRIPTION
The DEC Kanji codeset consists of the following characters: ASCII or JIS X0201 Roman letters Katakana characters specified by JIS X0201 JIS X0208 characters User-defined characters (UDC) DEC Kanji uses a combination of single-byte data and two-byte data to represent these characters. JIS X0201 is a single-byte character set and consists of Roman letters and Katakana characters, which are Japanese phonetic symbols. The Roman letters defined in the JIS X0201-1976 standard are the same as ASCII letters. (For information on the ASCII character set, refer to ascii(5).) However, JIS X0201 replaces the ASCII tilde (~) character with a horizontal bar (located at the upper part of a character cell), and replaces the backslash () with the Japanese currency sign (Yen). The JIS XO208 standard specifies two-byte character values that represent a variety of characters, including ideographic symbols. DEC Kanji Encoding All ASCII characters are represented by single-byte 7-bit values in DEC Kanji. That is, the most significant bit (MSB) is always set off in the byte that represents an ASCII character. The Roman letters and the Katakana characters specified by JIS X0201 are also single-byte val- ues in which the most significant bit (MSB) is set off and on, respectively. The code table for JIS X0208 characters is divided into 94 rows, numbered from 1 to 94. Each row has 94 columns, also numbered from 1 to 94. JIS X0208 defines a total of 6877 characters which include: Special symbols, in rows 1 and 2 Numerals and Roman letters, in row 3 Hira- gana characters, in row 4 Katakana characters, in row 5 Greek letters, in row 6 Russian letters, in row 7 Symbols for drawing graphs, dia- grams, and lines, in row 8 First level Kanji characters, in rows 16 to 47 Second level Kanji characters, in rows 48 to 84 To comply with the JIS X0208 standard, each JIS X0208 character is a two-byte value in the DEC Kanji codeset. The MSB of both the first and second bytes is always set on to distinguish JIS X0208 characters from ASCII/JIS Roman or user-defined characters. For each JIS X0208 character, The first byte of the two-byte value determines the row number and the second determines the column number in the JIS X0208 code table. The following formula shows the code value for a JIS X0208 character in relation to its row and column numbers: 1st byte = A0 + Row number 2nd byte = A0 + Column number For example, if a character is positioned at the first column of the 36th row, its code value is C4A1, which is calculated as follows: 1st byte = A0 (hex) + 36 = C4 (hex) 2nd byte = A0 (hex) + 01 = A1 (hex) For user-defined character (UDC) definitions, DEC Kanji provides an area of 2914 positions (from row 1 to row 31). Each UDC is represented by a two-byte value, just like a JIS X0208 character value. However, the MSB of the second byte of a UDC is set off to distinguish it from a JIS X0208 character. The code range of the UDC area is A121 to BF7E. The following formula calculates the code of a UDC in relation to its row and column numbers: 1st byte = A0 + Row number 2nd byte = 20 + Column number For example, if a UDC is positioned at the first column of the 16th row, its code value is B021, which is calculated as follows: 1st byte = A0 (hex) + 16 = B0 (hex) 2nd byte = 20 (hex) + 01 = 21 (hex) Codeset Conversion The following codeset converter pairs are available for converting Japanese characters between deckanji and other encoding formats. Refer to iconv_intro(5) for an introduction to codeset conversion. For more information about the other codeset for which deckanji is the input or output, see the reference page specified in the list item. eucJP_deckanji, deckanji_eucJP Converting from and to Japanese Extended UNIX Code: eucJP(5). iso-2022-jp_deckanji, deckanji_iso-2022-jp Converting from and to the ISO 2022-JP codeset: iso2022jp(5). iso-2022-jpext_deckanji, deckanji_iso-2022-jpext Converting from and to the ISO 2022-JPexp codeset: iso2022jp(5). JIS7_deckanji, deckanji_JIS7 Converting from and to the JIS7 codeset: jiskanji(5). sdeckanji_deckanji, deckanji_sdeckanji Converting from and to the Super DEC Kanji codeset: sdeckanji(5). SJIS_deckanji, deckanji_SJIS Converting from and to the Shift JIS codeset: shiftjis(5). Note that Shift JIS encoding is equivalent to the Microsoft code-page format used on PCs for Japanese. Therefore, you can use these converters to convert data between DEC Kanji and PC code-page format. For information on PC code pages, see code_page(5) UCS-2_deck- anji, deckanji_UCS-2 Converting from and to UCS-2 format: Unicode(5). UCS-4_deckanji, deckanji_UCS-4 Converting from and to UCS-4 format: Unicode(5). UTF-8_deckanji, deckanji_UTF-8 Converting from and to UTF--8 format: Unicode(5). Japanese Fonts The operating system provides the following Japanese bitmap fonts in various sizes and typefaces for 75dpi and 100dpi (dot-per-inch) dis- play devices: JIS X0201-1976 characters (Gothic family): -jdecw-gothic-medium-r-normal--8-80-75-75-m-40-jisx0201.1976-0 -jdecw-gothic-medium-r-normal--14-140-75-75-m-70-jisx0201.1976-0 -jdecw-gothic-medium-r-normal--12-120-75-75-m-60-jisx0201.1976-0 -jdecw-gothic-medium-r-normal--24-240-75-75-m-120-jisx0201.1976-0 -jdecw-gothic-medium-r-normal--10-100-75-75-m-50-jisx0201.1976-0 -jdecw-gothic-medium-r-normal--18-180-75-75-m-90-jisx0201.1976-0 -jdecw-gothic-medium-r-normal--17-120-100-100-m-85-jisx0201.1976-0 -jdecw-gothic-medium-r-nor- mal--34-240-100-100-m-170-jisx0201.1976-0 -jdecw-gothic-medium-r-normal--14-100-100-100-m-70-jisx0201.1976-0 -jdecw-gothic-medium-r- normal--25-180-100-100-m-125-jisx0201.1976-0 -jdecw-gothic-medium-r-normal--20-140-100-100-m-100-jisx0201.1976-0 -jdecw-gothic- medium-r-normal--11-80-100-100-m-55-jisx0201.1976-0 JIS X0201-1976 characters (Kmenu family) -jdecw-kmenu-medium-r-normal--12-120-75-75-p-70-jisx0201.1976-0 -jdecw-kmenu-medium-r-normal--17-120-100-100-p-85-jisx0201.1976-0 JIS X0201-1976 characters (Mincho family) -jdecw-mincho-medium-r-normal--8-80-75-75-m-40-jisx0201.1976-0 -jdecw-mincho-medium-r-normal--14-140-75-75-m-70-jisx0201.1976-0 -jdecw-mincho-medium-r-normal--24-240-75-75-m-120-jisx0201.1976-0 -jdecw-mincho-medium-r-normal--10-100-75-75-m-50-jisx0201.1976-0 -jdecw-mincho-medium-r-normal--18-180-75-75-m-90-jisx0201.1976-0 -jdecw-mincho-medium-r-normal--17-120-100-100-m-85-jisx0201.1976-0 -jdecw-mincho-medium-r-normal--34-240-100-100-m-170-jisx0201.1976-0 -jdecw-mincho-medium-r-nor- mal--14-100-100-100-m-70-jisx0201.1976-0 -jdecw-mincho-medium-r-normal--25-180-100-100-m-125-jisx0201.1976-0 -jdecw-mincho-medium-r- normal--20-140-100-100-m-100-jisx0201.1976-0 -jdecw-mincho-medium-r-normal--11-80-100-100-m-55-jisx0201.1976-0 JIS X0201-1976 char- acters (Screen family) -jdecw-screen-medium-r-normal--24-240-75-75-m-120-jisx0201-romankana -jdecw-screen-medium-r-nor- mal--18-180-75-75-m-80-jisx0201-romankana -jdecw-screen-medium-r-normal--14-140-75-75-m-70-jisx0201-romankana -jdecw-screen-medium- r-normal--10-100-75-75-m-50-jisx0201-romankana JIS X0208 characters (Gothic family) -jdecw-gothic-medium-r-normal--14-140-75-75-m-140-jisx0208.1983-1 -jdecw-gothic-medium-r-normal--12-120-75-75-m-120-jisx0208.1983-1 -jdecw-gothic-medium-r-normal--24-240-75-75-m-240-jisx0208.1983-1 -jdecw-gothic-medium-r-normal--10-100-75-75-m-100-jisx0208.1983-1 -jdecw-gothic-medium-r-normal--18-180-75-75-m-180-jisx0208.1983-1 -jdecw-gothic-medium-r-normal--8-80-75-75-m-80-jisx0208.1983-1 -jdecw-gothic-medium-r-normal--17-120-100-100-m-170-jisx0208.1983-1 -jdecw-gothic-medium-r-nor- mal--34-240-100-100-m-340-jisx0208.1983-1 -jdecw-gothic-medium-r-normal--14-100-100-100-m-140-jisx0208.1983-1 -jdecw-gothic-medium- r-normal--25-180-100-100-m-250-jisx0208.1983-1 -jdecw-gothic-medium-r-normal--20-140-100-100-m-200-jisx0208.1983-1 -jdecw-gothic- medium-r-normal--11-80-100-100-m-110-jisx0208.1983-1 JIS X0208 characters (Mincho family) -jdecw-mincho-medium-r-normal--14-140-75-75-m-140-jisx0208.1983-1 jdecw-mincho-medium-r-normal--12-120-75-75-m-120-jisx0208.1983-1 -jdecw-mincho-medium-r-normal--24-240-75-75-m-240-jisx0208.1983-1 -jdecw-mincho-medium-r-normal--10-100-75-75-m-100-jisx0208.1983-1 -jdecw-mincho-medium-r-normal--18-180-75-75-m-180-jisx0208.1983-1 -jdecw-mincho-medium-r-normal--8-80-75-75-m-80-jisx0208.1983-1 -jdecw-mincho-medium-r-normal--17-120-100-100-m-170-jisx0208.1983-1 -jdecw-mincho-medium-r-nor- mal--34-240-100-100-m-340-jisx0208.1983-1 -jdecw-mincho-medium-r-normal--14-100-100-100-m-140-jisx0208.1983-1 -jdecw-mincho-medium- r-normal--25-180-100-100-m-250-jisx0208.1983-1 -jdecw-mincho-medium-r-normal--20-140-100-100-m-200-jisx0208.1983-1 -jdecw-mincho- medium-r-normal--11-80-100-100-m-110-jisx0208.1983-1 JIS X0208 characters (Screen family) -jdecw-screen-medium-r-normal--24-240-75-75-m-240-jisx0208-kanji00 -jdecw-screen-medium-r-nor- mal--10-100-75-75-m-100-jisx0208-kanji00 -jdecw-screen-medium-r-normal--18-180-75-75-m-160-jisx0208-kanji00 -jdecw-screen-medium-r- normal--16-160-75-75-m-160-jisx0208-kanji00 -jdecw-screen-medium-r-normal--14-140-75-75-m-140-jisx0208-kanji00 -jdecw-screen-medium- r-normal--24-240-75-75-m-240-jisx0208-kanji11 -jdecw-screen-medium-r-normal--10-100-75-75-m-100-jisx0208-kanji11 -jdecw-screen- medium-r-normal--18-180-75-75-m-160-jisx0208-kanji11 -jdecw-screen-medium-r-normal--14-140-75-75-m-140-jisx0208-kanji11 For printers, the operating system provides only Japanese fonts that are printer-resident; that is, there are no Japanese fonts that can be dynamically down-loaded to the printer. Refer to i18n_printing(5) for general information on printing non-English text. SEE ALSO
Commands: locale(1) Others: ascii(5), code_page(5), eucJP(5), i18n_intro(5), i18n_printing(5), iconv_intro(5), iso2022jp(5), Japanese(5), jiskanji(5), sdeck- anji(5), shiftjis(5), Unicode(5) deckanji(5)
All times are GMT -4. The time now is 06:04 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy