Sponsored Content
Full Discussion: Joining
Top Forums Shell Programming and Scripting Joining Post 302797993 by Corona688 on Tuesday 23rd of April 2013 02:55:24 PM
Old 04-23-2013
Code:
awk '

F != FILENAME { FILENO++ ; F=FILENAME }
{ A[$1,FILENO]=$2 }
!($1 in C) { C[$1]++; COL[++L]=$1 }

END {
        for(N=1; N<=L; N++)
        {
                printf("%d", COL[N]+0);
                for(FILE=1; FILE<=FILENO; F++)
                        printf(" %d", A[COL[N],FILE]+0);
                printf("\n");
        }
}' file1 file2 file3 ...

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

joining 2 files

Hi, I have two files that I need to find difference between. Do I use diff or join? If join, how do I use it? thanks, webtekie (1 Reply)
Discussion started by: webtekie
1 Replies

2. Shell Programming and Scripting

Help with joining two files

Greetings, all. I've got a project that requires I join two data files together, then do some processing and output. Everything must be done in a shell script, using standard unix tools. The files look like the following: File_1 Layout: Acct#,Subacct#,Descrip Sample: ... (3 Replies)
Discussion started by: rjlohman
3 Replies

3. Shell Programming and Scripting

Joining Variables

Hi Everyone, Thanks in advance for what is hopefully a simple thing. Big picture I am trying to bind computers to AD using their existing name but add a suffix. Here is the part I am having trouble with: computername=`/usr/sbin/scutil --get LocalHostName` suffix=suffix... (2 Replies)
Discussion started by: dcc186
2 Replies

4. Shell Programming and Scripting

Joining of Commands.

Hello, i have a few questions which i hope you guys can address. the 1st prob: The database i am using is a text file which displays the information like this : Title : Quantity : Price Persia : 30 : 20 ... (5 Replies)
Discussion started by: gregarion
5 Replies

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

6. Shell Programming and Scripting

variable joining

I really need help on this problem. The story: My VAR1 and VAR2 works fine and able to get the value. I want to do as "if VAR1 or VAR2 is bigger than max_loadavg then the code will run...then if VAR1 or VAR2 is lesser than min_loadavg then the other code will run... The problem: The... (8 Replies)
Discussion started by: hezry79
8 Replies

7. Shell Programming and Scripting

Joining Three Files

Hi guys, I have three files which needs to be joined to a single file. File 1: Col a, Col b, Col c File 2: Col 1a, Col 1b File 3: Col 2a, Col 2b Output: Col 1a, Col 2a, Col a, Col b, Col c. All the files are comma delimited. I need to join Col b with Col 1b and need to... (17 Replies)
Discussion started by: mac4rfree
17 Replies

8. Shell Programming and Scripting

Joining 2 Files

File "A" (column names: Nickname Number GB) Nickname Number GB PROD_DB0034 100A 16 ASMIL1B_DATA_003 100B 16 PSPROD_0000 1014 36 PSPROD_0001 100D 223 ..... File "B" (column names: TYPE DEVICE NUMBER SIZE) TYPE DEVICE NUMBER SIZE 1750500 hdisk2 100A 16384 1750500 hdisk3 ... (4 Replies)
Discussion started by: Daniel Gate
4 Replies

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

10. Shell Programming and Scripting

Please help me in joining two files

I have two files with the below contents : sampleoutput3.txt 20150202;hostname1 20150223;hostname2 20150716;hostname3 sampleoutput1.txt hostname;packages_out_of_date;errata_out_of_date; hostname1;11;0; hostnamea;12;0; hostnameb;11;0; hostnamec;95;38; hostnamed;440;358;... (2 Replies)
Discussion started by: rahul2662
2 Replies
REFORMAIL(1)						      Double Precision, Inc.						      REFORMAIL(1)

NAME
reformail - E-mail reformatting tool SYNOPSIS
reformail -s command [option...] reformail -D len filename reformail -x header:... reformail -X header:... reformail [options...] See below for additional options DESCRIPTION
The reformail program reads a message on standard input, reformats it in some way, and writes the message to standard output: Splitting mailboxes into individual messages The -s option splits the mbox-formatted mailbox file on standard input into individual messages. An external program is executed for each message. The contents of each individual message will be provided to the external program on standard input. If the FILENO environment variable is set to a number, reformail will consecutively increment FILENO each time the program is executed for each individual message. If FILENO is not set, it's initial value will be "000". If FILENO is set to a non-numeric value, FILENO will remain unchanged. Detecting duplicate messages The -D option implements a simple way to delete duplicate messages in incoming mail. filename is a file that will be approximately 'len' bytes long. This file will be used by reformail to save message IDs seen in recent mail. reformail reads the message on standard input. If the message has a Message-ID: header that's already in the cache file, reformail terminates with the exit code set to 0. Otherwise, reformail terminates with the exit code set to 1. Extracting headers The -x and -X options extract the indicated headers from the message, and print them to standard output. Multiple -x and -X options can be specified at the same time, and may be intermixed. The -x option extracts and prints the contents of the header. The -X option prints the name of the header as well. In all other situations, reformail copies the message on its standard input to its standard output, reformatting the message as follows: OPTIONS
-a'header: value' Append a custom header to the message if this header does not already exist. If the header is either Message-ID: or Resent-Message-ID: and the value is empty, reformail generates a (hopefully) unique message ID for you. -A'header: value' Append a custom header to the message even if this header already exists. If the header is either Message-ID: or Resent-Message-ID: and the value is empty, reformail generates a (hopefully) unique message ID for you. -c Concatenate multi-line headers. Headers split on multiple lines are combined into a single line. -dn If n is 1, each line will be terminated with CRLF. If n is 0 (default), each line will be terminated with LF. reformail reads a message with either line terminator, and will force the message to have the specified line termination. -f0 Remove the "From_" line from the message, if it's there. -f1 Add the "From_" line to the message, if it's not there. reformail will attempt to generate the "From_" line from any Errors-To:, Return-Path:, or From: headers in the message. "root" will be used if reformail is unable to determine the return address. -i'header: value' Appends a custom header to the message. If this header already exists it is renamed by prepending "Old-" to the name of the header. -I'header: value' Append a custom header to the message. If this header already exists in the message, the old header is completely removed. If the value is empty, any existing header is completely removed, and nothing gets appended. -R oldheader: newheader: Rename the indicated header. -u'header:' If this header occurs multiple times in the message, remove all occurrences except the first one. -U'header:' If this header occurs multiple times in the message, remove all occurrences except the last one. AUTOREPLIES
The autoreply options from earlier versions of mailbot have been moved into mailbot(1)[1]. BUGS
For the -a, -A, and -I options, a space after the header name and the colon is considered to be a non-empty field. Do not provide the same header to more than one family of header-modifying options, such as -u/-U and -a/-A. Doing so yields unpredictable results. It's better to run reformail several times (use a pipe, perhaps). SEE ALSO
courier(8)[2], sendmail(8), mailbot(1)[1], maildrop(1)[3]. AUTHOR
Sam Varshavchik Author NOTES
1. mailbot(1) [set $man.base.url.for.relative.links]/mailbot.html 2. courier(8) [set $man.base.url.for.relative.links]/courier.html 3. maildrop(1) [set $man.base.url.for.relative.links]/maildrop.html Courier Mail Server 08/30/2011 REFORMAIL(1)
All times are GMT -4. The time now is 10:32 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy