Sponsored Content
Top Forums Shell Programming and Scripting Help with merge two file based on similar column content Post 302523601 by zaxxon on Thursday 19th of May 2011 06:57:49 AM
Old 05-19-2011
I changed the order of those two files ie. file 1 is f2 and file 2 is f1 in your case:
Code:
awk 'NR==FNR{_[$1]=$2; next} _[$1] {print $1,_[$1]; next} {print $1,"Undefined"}' f1 f2
A1BG All
A1BG All
A1BG All
A1CF TEMP
A1CF TEMP
BCAS Undefined
BCAS Undefined
A2LD1 STOP
A2M KEEP
A2M KEEP
HAT Undefined

This User Gave Thanks to zaxxon For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

merge rows based on a common column

Hi guys, Please guide me if you have a solution to this problem. I have tried paste -s but it's not giving the desired output. I have a file with the following content- A123 box1 B345 bat2 C431 my_id A123 service C431 box1 A123 my_id I need two different outputs- OUTPUT1 A123... (6 Replies)
Discussion started by: smriti_shridhar
6 Replies

2. Shell Programming and Scripting

Merge Two Files based on First column

Hi, I need to join two files based on first column of both files.If first column of first file matches with the first column of second file, then the lines should be merged together and go for next line to check. It is something like: File one: 110001 abc efd 110002 fgh dfg 110003 ... (10 Replies)
Discussion started by: apjneeraj
10 Replies

3. Shell Programming and Scripting

merge two two txt files into one file based on one column

Hi, I have file1.txt and file2.txt and would like to create file3.txt based on one column in UNIX Eg: file1.txt 17328756,0000786623.pdf,0000786623 20115537,0000793892.pdf,0000793892 file2.txt 12521_74_4.zip,0000786623.pdf 12521_15_5.zip,0000793892.pdf Desired Output ... (5 Replies)
Discussion started by: techmoris
5 Replies

4. Shell Programming and Scripting

Joining multiple files based on one column with different and similar values (shell or perl)

Hi, I have nine files looking similar to file1 & file2 below. File1: 1 ABCA1 1 ABCC8 1 ABR:N 1 ACACB 1 ACAP2 1 ACOT1 1 ACSBG 1 ACTR1 1 ACTRT 1 ADAMT 1 AEN:N 1 AKAP1File2: 1 A4GAL 1 ACTBL 1 ACTL7 (4 Replies)
Discussion started by: seqbiologist
4 Replies

5. Shell Programming and Scripting

Help with replace column one content based on reference file

Input file 1 testing 10 20 1 A testing 20 40 1 3 testing 23 232 2 1 testing 10 243 2 . . Reference file 1 final 3 used . . Output file (2 Replies)
Discussion started by: perl_beginner
2 Replies

6. Shell Programming and Scripting

Help with replace column one content based on reference file

Input file 1 testing 10 20 1 A testing 20 40 1 3 testing 23 232 2 1 testing 10 243 2 . . Reference file 1 final 3 used . . Output file (1 Reply)
Discussion started by: perl_beginner
1 Replies

7. Shell Programming and Scripting

Merge two files with similar column entries

Hi , I have few files which contains user name and data transfer rate in MBs and this data is collected for year and for each month report is saved in 12 different files I have to merge all the files to prepare the final report Files are as below Similarly I have 10 more files ... (5 Replies)
Discussion started by: pratapsingh
5 Replies

8. UNIX for Dummies Questions & Answers

Find the average based on similar names in the first column

I have a table, say this: name1 num1 num2 num3 num4 name2 num5 num6 num7 num8 name3 num1 num3 num4 num9 name2 num8 num9 num1 num2 name2 num4 num5 num6 num4 name4 num4 num5 num7 num8 name5 num1 num3 num9 num7 name5 num6 num8 num3 num4 I want a code that will sort my data according... (4 Replies)
Discussion started by: FelipeAd
4 Replies

9. Shell Programming and Scripting

Merge files based on the column value

Hi Friends, I have a file file1.txt 1|ABC|3|jul|dhj 2|NHU|4|kil|eu 3|hjd|34|hfd|43 file2.txt 1||3|KING|dhj 2|NHU||k| 3|hjd|34|hd|43 i want to merge file1.txt file2.txt based on the column null values in file2.txif there are any nulls in column values , (5 Replies)
Discussion started by: i150371485
5 Replies

10. UNIX for Dummies Questions & Answers

How to merge two tables based on a matched column?

Hi, Please excuse me , i have searched unix forum, i am unable to find what i expect , my query is , i have 2 files of same structure and having 1 similar field/column , i need to merge 2 tables/files based on the one matched field/column (that is field 1), file 1:... (5 Replies)
Discussion started by: karthikram
5 Replies
httpd_util(3erl)					     Erlang Module Definition						  httpd_util(3erl)

NAME
httpd_util - Miscellaneous utility functions to be used when implementing Erlang Web server API modules. DESCRIPTION
This module provides the Erlang Web Server API module programmer with miscellaneous utility functions. EXPORTS
convert_request_date(DateString) -> ErlDate|bad_date Types DateString = string() ErlDate = {{Year,Month,Date},{Hour,Min,Sec}} Year = Month = Date = Hour = Min = Sec = integer() convert_request_date/1 converts DateString to the Erlang date format. DateString must be in one of the three date formats that is defined in the RFC 2616. create_etag(FileInfo) -> Etag Types FileInfo = file_info() Etag = string() create_etag/1 calculates the Etag for a file, from its size and time for last modification. fileinfo is a record defined in ker- nel/include/file.hrl decode_hex(HexValue) -> DecValue Types HexValue = DecValue = string() Converts the hexadecimal value HexValue into its decimal equivalent ( DecValue ). day(NthDayOfWeek) -> DayOfWeek Types NthDayOfWeek = 1-7 DayOfWeek = string() day/1 converts the day of the week ( NthDayOfWeek ) as an integer (1-7) to an abbreviated string, that is: 1 = "Mon", 2 = "Tue", ..., 7 = "Sat". flatlength(NestedList) -> Size Types NestedList = list() Size = integer() flatlength/1 computes the size of the possibly nested list NestedList . Which may contain binaries. hexlist_to_integer(HexString) -> Number Types Number = integer() HexString = string() hexlist_to_integer Convert the Hexadecimal value of HexString to an integer. integer_to_hexlist(Number) -> HexString Types Number = integer() HexString = string() integer_to_hexlist/1 Returns a string that represents the Number in a Hexadecimal form. lookup(ETSTable,Key) -> Result lookup(ETSTable,Key,Undefined) -> Result Types ETSTable = ets_table() Key = term() Result = term() | undefined | Undefined Undefined = term() lookup extracts {Key,Value} tuples from ETSTable and returns the Value associated with Key . If ETSTable is of type bag only the first Value associated with Key is returned. lookup/2 returns undefined and lookup/3 returns Undefined if no Value is found. lookup_mime(ConfigDB,Suffix) lookup_mime(ConfigDB,Suffix,Undefined) -> MimeType Types ConfigDB = ets_table() Suffix = string() MimeType = string() | undefined | Undefined Undefined = term() lookup_mime returns the mime type associated with a specific file suffix as specified in the mime.types file (located in the config directory ). lookup_mime_default(ConfigDB,Suffix) lookup_mime_default(ConfigDB,Suffix,Undefined) -> MimeType Types ConfigDB = ets_table() Suffix = string() MimeType = string() | undefined | Undefined Undefined = term() lookup_mime_default returns the mime type associated with a specific file suffix as specified in the mime.types file (located in the config directory ). If no appropriate association can be found the value of DefaultType is returned. message(StatusCode,PhraseArgs,ConfigDB) -> Message Types StatusCode = 301 | 400 | 403 | 404 | 500 | 501 | 504 PhraseArgs = term() ConfigDB = ets_table Message = string() message/3 returns an informative HTTP 1.1 status string in HTML. Each StatusCode requires a specific PhraseArgs : 301 : string() : A URL pointing at the new document position. 400 | 401 | 500 : none (No PhraseArgs ) 403 | 404 : string() : A Request-URI as described in RFC 2616. 501 : {Method,RequestURI,HTTPVersion} : The HTTP Method , Request-URI and HTTP-Version as defined in RFC 2616. 504 : string() : A string describing why the service was unavailable. month(NthMonth) -> Month Types NthMonth = 1-12 Month = string() month/1 converts the month NthMonth as an integer (1-12) to an abbreviated string, that is: 1 = "Jan", 2 = "Feb", ..., 12 = "Dec". multi_lookup(ETSTable,Key) -> Result Types ETSTable = ets_table() Key = term() Result = [term()] multi_lookup extracts all {Key,Value} tuples from an ETSTable and returns all Values associated with the Key in a list. reason_phrase(StatusCode) -> Description Types StatusCode = 100| 200 | 201 | 202 | 204 | 205 | 206 | 300 | 301 | 302 | 303 | 304 | 400 | 401 | 402 | 403 | 404 | 405 | 406 | 410 411 | 412 | 413 | 414 415 | 416 | 417 | 500 | 501 | 502 | 503 | 504 | 505 Description = string() reason_phrase returns the Description of an HTTP 1.1 StatusCode , for example 200 is "OK" and 201 is "Created". Read RFC 2616 for further information. rfc1123_date() -> RFC1123Date rfc1123_date({{YYYY,MM,DD},{Hour,Min,Sec}}}) -> RFC1123Date Types YYYY = MM = DD = Hour = Min =Sec = integer() RFC1123Date = string() rfc1123_date/0 returns the current date in RFC 1123 format. rfc_date/1 converts the date in the Erlang format to the RFC 1123 date format. split(String,RegExp,N) -> SplitRes Types String = RegExp = string() SplitRes = {ok, FieldList} | {error, errordesc()} Fieldlist = [string()] N = integer split/3 splits the String in N chunks using the RegExp . split/3 is is equivalent to regexp:split/2 with one exception, that is N defines the number of maximum number of fields in the FieldList . split_script_path(RequestLine) -> Splitted Types RequestLine = string() Splitted = not_a_script | {Path, PathInfo, QueryString} Path = QueryString = PathInfo = string() split_script_path/1 is equivalent to split_path/1 with one exception. If the longest possible path is not a regular, accessible and executable file not_a_script is returned. split_path(RequestLine) -> {Path,QueryStringOrPathInfo} Types RequestLine = Path = QueryStringOrPathInfo = string() split_path/1 splits the RequestLine in a file reference ( Path ) and a QueryString or a PathInfo string as specified in RFC 2616. A QueryString is isolated from the Path with a question mark ( ? ) and PathInfo with a slash (/). In the case of a QueryString , everything before the ? is a Path and everything after a QueryString . In the case of a PathInfo the RequestLine is scanned from left-to-right on the hunt for longest possible Path being a file or a directory. Everything after the longest possible Path , iso- lated with a / , is regarded as PathInfo . The resulting Path is decoded using decode_hex/1 before delivery. strip(String) -> Stripped Types String = Stripped = string() strip/1 removes any leading or trailing linear white space from the string. Linear white space should be read as horizontal tab or space. suffix(FileName) -> Suffix Types FileName = Suffix = string() suffix/1 is equivalent to filename:extension/1 with one exception, that is Suffix is returned without a leading dot ( . ). SEE ALSO
httpd(3erl) Ericsson AB inets 5.5.2 httpd_util(3erl)
All times are GMT -4. The time now is 03:52 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy