Sponsored Content
Top Forums Shell Programming and Scripting Compare columns of multiple files and print those unique string from File1 in an output file. Post 302863835 by Don Cragun on Tuesday 15th of October 2013 07:35:42 AM
Old 10-15-2013
A slight simplification of pravin27's script:
Code:
awk '
FNR == NR { l[$0]; next }
$0 in l { delete l[$0] }
END { for(i in l) print i } 
' File*

As always, if you want to try this on a Solaris/SunOS system, use /usr/xpg4/bin/awk, /usr/xpg6/bin/awk, or nawk instead of just awk.
These 2 Users Gave Thanks to Don Cragun For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

compare columns from seven files and print the output

Hi guys, I need some help to come out with a solution . I have seven such files but I am showing only three for convenience. filea a5 20 a8 16 fileb a3 42 a7 14 filec a5 23 a3 07 The output file shoud contain the data in table form showing first field of... (7 Replies)
Discussion started by: smriti_shridhar
7 Replies

2. Shell Programming and Scripting

Compare multiple fields in file1 to file2 and print line and next line

Hello, I have two files that I need to compare and print out the line from file2 that has the first 6 fields matching the first 6 fields in file1. Complicating this are the following restrictions 1. file1 is only a few thousand lines at most and file2 is greater than 2 million 2. I need to... (7 Replies)
Discussion started by: gillesc_mac
7 Replies

3. Shell Programming and Scripting

compare two columns of different files and print the matching second file..

Hi, I have two tab separated files; file1: S.No ddi fi cu o/l t+ t- 1 0.5 0.6 o 0.1 0.2 2 0.2 0.3 l 0.3 0.4 3 0.5 0.8 l 0.1 0.6 ... (5 Replies)
Discussion started by: vasanth.vadalur
5 Replies

4. Programming

Compare two files of 4 columns and o/p unique,append zero's

I have to files File1 1 23 2 34 3 7 4 56 5 61 6 22 7 65 File2 2 21 4 32 7 22 Now i need to compare column1 of both the files and generate a third file which should contain all the values of 1st column of 1st file and in the second column i need to get the coressponding row... (2 Replies)
Discussion started by: kamuju
2 Replies

5. Shell Programming and Scripting

awk compare specific columns from 2 files, print new file

Hello. I have two files. FILE1 was extracted from FILE2 and modified thanks to help from this post. Now I need to replace the extracted, modified lines into the original file (FILE2) to produce the FILE3. FILE1 1466 55.27433 14.72050 -2.52E+03 3.00E-01 1.05E+04 2.57E+04 1467 55.27433... (1 Reply)
Discussion started by: jm4smtddd
1 Replies

6. Shell Programming and Scripting

Compare multiple files and print unique lines

Hi friends, I have multiple files. For now, let's say I have two of the following style cat 1.txt cat 2.txt output.txt Please note that my files are not sorted and in the output file I need another extra column that says the file from which it is coming. I have more than 100... (19 Replies)
Discussion started by: jacobs.smith
19 Replies

7. Shell Programming and Scripting

Compare multiple files, identify common records and combine unique values into one file

Good morning all, I have a problem that is one step beyond a standard awk compare. I would like to compare three files which have several thousand records against a fourth file. All of them have a value in each row that is identical, and one value in each of those rows which may be duplicated... (1 Reply)
Discussion started by: nashton
1 Replies

8. Shell Programming and Scripting

[Solved] awk compare two different columns of two files and print all from both file

Hi, I want to compare two columns from file1 with another two column of file2 and print matched and unmatched column like this File1 1 rs1 abc 3 rs4 xyz 1 rs3 stu File2 1 kkk rs1 AA 10 1 aaa rs2 DD 20 1 ccc ... (2 Replies)
Discussion started by: justinjj
2 Replies

9. UNIX for Dummies Questions & Answers

Compare file1 and file2, print matching lines in same order as file1

I want to print only the lines in file2 that match file1, in the same order as they appear in file 1 file1 file2 desired output: I'm getting the lines to match awk 'FNR==NR {a++}; FNR!=NR && a' file1 file2 but they are in sorted order, which is not what I want: Can anyone... (4 Replies)
Discussion started by: pathunkathunk
4 Replies

10. UNIX for Beginners Questions & Answers

Split into multiple files by using Unique columns in a UNIX file

I have requirement to split below file (sample.csv) into multiple files by using the unique columns (first 3 are unique columns) sample.csv 123|22|56789|ABCDEF|12AB34|2019-07-10|2019-07-10|443.3400|1|1 123|12|5679|BCDEFG|34CD56|2019-07-10|2019-07-10|896.7200|1|2... (3 Replies)
Discussion started by: RVSP
3 Replies
nljust(1)						      General Commands Manual							 nljust(1)

NAME
nljust - justify lines, left or right, for printing SYNOPSIS
digits] seq] just] mode] order] margin] width] ck] [file ...] DESCRIPTION
formats for printing data written in languages with a right-to-left orientation. It is designed to be used with the and the commands (see pr(1) and lp(1)). reads the concatenation of input files (or standard input if none are given) and produces on standard output a right-to-left formatted ver- sion of its input. If appears as an input file name, reads standard input at that point. Use to delimit the end of options. formats input files for all languages that are read from right to left. For languages that have a left-to-right orientation, the command merely copies input files to standard output. Options recognizes the following options: Justify data for all languages, including those having a left-to-right text orientation. By default only right-to-left language data is justified. For all other languages, input files are directly copied to standard output. Select enhanced printer shapes for some Arabic characters. With this option, two-character combinations of laam and alif are replaced by a single character. Triggers ISO 8859-6 interpretation of the data. Processes digits for output as hindi, western, or both. digits can be or both. Use seq as the escape sequence to select the primary character set. This escape sequence is used by languages that have too many characters to be accommodated by ASCII in a single 256-character set. In these cases, the seq escape sequence can be used to select the non-ASCII character set. The escape character itself(0x1b) is not given on the command line. Hewlett-Packard escape sequences are used by default. If just is left justify print lines. If just is right-justify print lines starting from the (designated or default) print width column. The default is right justification. Replace leading spaces with alternative spaces. Some right-to-left character sets have a non-ASCII or alternative space. This option can be useful when filtering out- put (see pr(1)). With right justification, the option causes line numbers to be placed immediately to the right of the tab character. Without the option, right justification causes line numbers to be placed at the print-width column. By default, leading spaces are not replaced by alternative spaces. Indicate mode of any file to be formatted. Mode refers to the text orientation of the file when it was created. If mode is assume Latin mode. If mode is assume non-Latin mode. By default, mode information is obtained from the environment variable. Do not terminate lines containing printable characters with a new-line. By default, print lines are terminated by new-lines. Indicate data order of any file to be formatted. The text orientation of a file can affect the way its data is arranged. If order is assume keyboard order. If order is assume screen order. By default, order information is obtained from the environment variable. Truncate print lines that do not fit the designated or default line length. Print lines are folded (that is, wrapped to next line) by default. Expand input tabs to column positions k+1, 2*k+1, 3*k+1, etc. Tab characters in the input are expanded to the appropriate number of spaces. If k is 0 or is omitted, default tab settings at every eighth position is assumed. If cd (any non-digit character) is given, it is treated as the input tab character. The default for c is the tab character. always expands input tabs. This option provides a way to change the tab character and setting. If this option is specified, at least one of the parameters c or k must be given. Designate a number as the print margin. The print margin is the column where truncation or folding takes place. The print margin determines how many characters appear on a single line and can never exceed the print width. The print margin is relative to the justifica- tion. If the print margin is 80, folding or truncation occurs at column 80 starting from the right during a right jus- tification. Similarly, folding or truncation occurs at column 80 starting from the left during a left justification. By default, the print margin is set to column 80. Designates a number as the print width. The print width is the maximum number of columns in the print line. Print width determines the start of text during a right justification. The larger the print width, the further to the right the text will start. By default, an 80-column print width is used. EXTERNAL INFLUENCES
Environment Variables The environment variable determines the mode and order of the file. The syntax of is [mode][_order]. mode describes the mode of a file where represents Latin mode and represents non-Latin mode. Non-Latin mode is assumed for values other than and order describes the data order of a file where is keyboard and is screen. Keyboard order is assumed for values other than and Mode and order information in can be overridden from the command line. The environment variable determines the direction of a language (left-to-right or right-to-left) and whether context analysis of characters is necessary. The environment variable determines whether a language has alternative numbers. The environment variable determines the language in which messages are displayed. International Code Set Support Single-byte character code sets are supported. EXAMPLES
Right justify on a 132-column printer with a print margin at column 80 (the default): Right justify output of with line numbers on a 132-column printer with a print margin at column 132: WARNINGS
If with line numbers option) is piped to the separator character must be a tab(0x09). It is the user's responsibility to ensure that the environment variable accurately reflects the status of the file. Mode and justification must be consistent. Only non-Latin-mode files can be right justified in a meaningful way. Similarly, only Latin- mode files can be safely left justified. If mode and justification do not match, the results are undefined. If present, alternative numbers always have a left-to-right orientation. The command is HP proprietary, not portable to other vendors' systems, and will not be provided in future HP-UX releases. AUTHOR
was developed by HP. SEE ALSO
forder(1), lp(1), pr(1), strord(3C). nljust(1)
All times are GMT -4. The time now is 07:44 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy